...

View Full Version : load order



jerblaster23
12-07-2005, 02:39 AM
is it possable to control the load order of my page, I notice that the text loads first then my java script which changes the pages organization, is it possable for the java script to load first then the text will load last, thereby you don't see the change, it's very slight but I notice it on a dial up and would really like it if I could get the java scrip to load first, it is embedied in the header, if that matters. and I don't know much about programing so dumb down your explanation, thanks

mark87
12-07-2005, 09:08 AM
How are you running the javascript?

If you have it in a function and are calling it with onload then I think that could be your problem and you could try placing it within the head tags without the function (which will make it run automatically).

jerblaster23
12-07-2005, 11:02 AM
it is in the header:


<head>
<script type="text/javascript">

function zapLink() {

var allLinks = document.getElementsByTagName('a');
for (i=0; i<allLinks.length; i++) {
var thisLink = allLinks[i];
if (thisLink.href.indexOf('google.com') != -1) {
thisLink.parentNode.removeChild(thisLink);
}
}

}

window.onload = zapLink;

</script>
</head>
<body>

how do I make it run automaticley? sorry I don't know much about coding so if you can explain it really simple.

mark87
12-07-2005, 02:10 PM
Well you could remove the function, but I'm not sure if it would help or not to be honest, you could give it a try though -


<head>
<script type="text/javascript">
var allLinks = document.getElementsByTagName('a');
for (i=0; i<allLinks.length; i++) {
var thisLink = allLinks[i];
if (thisLink.href.indexOf('google.com') != -1) {
thisLink.parentNode.removeChild(thisLink);
}
}
</script>
</head>

Thing is, I suspect it may have to make the page load fully before it can search for the links and then remove them.

EDIT, I found this, see if it's any use - http://scott.yang.id.au/2003/07/javascript-load-order-with-defer-attribute/ - It seems to say that onload will load last, whereas what I have done above should load first.

jerblaster23
12-07-2005, 07:16 PM
it didn't work, the script never exicuted.

I found another page explaining this topic if you can make any since of it http://simon.incutio.com/archive/2004/05/26/addLoadEvent

also found this: http://www.bobbyvandersluis.com/articles/dynamicCSS.php

I don't really know if these solutions will work or not, but it's what the pages are about so if you can take a look and tell me what you think.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum