[jQuery] How to load remoate jquery code with document.write() that works with IE6/7?
I have a problem with IE (6 & 7) when I have something like this:
<script type="text/javascript" src="http://domain.com/
generateCode.php"></script>
and the server returns HTML and JS in place using document.write(),
such as:
<script type="text/javascript">
document.write('
<div id="x">TESTING</div>
<script type="text/javascript" src="http://domain2.com/
jquery.js"></script>
<script type="text/javascript">
$().ready({
$('#x').css("color:red");
});
);
</script>
IE6 & IE7 would give me script error, Error: Object expected. But FF
is fine.
I found 2 solutions,
a.) use defer="true"
<script type="text/javascript" src="http://domain.com/
generateCode.php" defer="true"></script>
b.) server returns JS that use window.onload instead of $().ready()
Are there any other solutions?
Thank you