I have a page that does the following:
The browser loads a very simple page with a valid head and body, with only a couple of script / noscript as content.
There is a script (script a) in the body that executes the onLoad function. This function dynamically turns on the second script (script b) and runs the function in it when it becomes available.
The second script is a .js file that performs various actions.
Both scripts are parsed by PHP and use the application content type / x-javascript.
Now everything works fine for me, except for a pair of JS-hiccups. JavaScript is not one of my strong languages, so I hope these are simple problems and someone can point me in the right direction.
Problem 1: If I make a simple warning ("you are in script b"); in the second script, it works as expected. However, if I do something, it works fine, and then the browser shows that it loads forever. This is a color animation in firefox, or a spinning thing in IE.
I tried to finish the script in different ways and nothing helps. Any idea how to tell the browser that the script is fully loaded? This is a .js file that is forced to parse through PHP.
2: script, , Opera, Google Chrome. FF/IE, . - , -, script?
!
Update:
. firebug, , ( , FF). , script Opera/Chrome, .
= o) Firebug , , . - , , , script b alert ('whatever'); , , , script document.write('whatever); .
, , net firegug:
, discoverfire.net - , ...
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Welcome!</title>
<style>body { font-family:arial; }</style>
<script language="JavaScript" type="text/javascript" src="http://www.discoverfire.net/analytics/l/a.js">
</script>
<script language="JavaScript" type="text/javascript">
document.onload = Start();
function Start(){
TAFKing_version = '1.0';
TAFKing_lkey = '19-8O-KKA8HV';
TAFKing_Lander();
}
</script>
</head>
<body>
<noscript>
Oops! We can't forward you properly because your JavaScript is turned off.<br /><br />
<a href='http://www.discoverfire.net/analytics/l/noscript/19-8O-KKA8HV.html'>Please click here to continue.</a>
<img src='http://www.discoverfire.net/analytics/l/imp/19-8O-KKA8HV.png' border='0' alt='tell a friend' />
</noscript>
</body>
</html>
** script A (... a.js): http://www.discoverfire.net/analytics/l/a.js **
function TAFKing_Lander(){
version = TAFKing_version;
lkey = TAFKing_lkey;
var scrb = document.createElement('script');
scrb.type = 'text/javascript';
scrb.src = 'http://www.discoverfire.net/analytics/l/b.js?lkey='+lkey+'&version='+version+'&cb=4eohe8e65'
;
document.getElementsByTagName('head')[0].appendChild(scrb);
Interval = setInterval("Waiter()", 10);
return;
}
function Waiter(){
if(window.TAFKing_LanderB) {
clearInterval(Interval);
TAFKing_LanderB();
}
}
Script B (... b.js): http://www.discoverfire.net/analytics/l/b.js?lkey=19-8O-KKA8HV&version=1.0&cb=4eohe8e65
function TAFKing_LanderB(){
document.write("there are just a whole bunch of doc.writes here that build a simple table");
}