This is a test page I made trying to figure out what’s going on behind the javascript scenes.
While the .htm produces output at first, it is being overriden as soon as the javascript executes the document.write() function after loading the page.[b]WHY?
How, or is it possible at all to [i] append
Also in Mozilla Firefox this produces and endless loop of alerts…it seems that the ‘onload’ event is triggered over and over again by the document.write() function.
On the other hand in Internet Explorer this is not the case. The alert comes only once.
This is the page. [COLOR=red]WARNING
[URL=http://www.maciej64d.1go.dk/event/event_test.htm]http://www.maciej64d.1go.dk/event/event_test.htm
[COLOR=darkblue]event_test.htm
[CODE]
<html>
<head>
<script src=”event_test.js” type=”text/javascript”></script>
</head>
<body>
<p>dude</p><p>dude2</p>
simple text
</body>
</html>
[COLOR=darkblue]event_test.js
[CODE]
addEvent(window, ‘load’, pageInit);
function pageInit () {
alert(“Page Loaded…”);
document.write(“javascript writing..”);
document.close();
}
/* addEvent by Scott Andrew */
function addEvent(obj, evType, fn){
if (obj.addEventListener) {
obj.addEventListener(evType, fn, true);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent(“on”+evType, fn);
return r;
} else {
return false;
}
}