[Javascript] Handle several window.onload functions

Guillaume javascript at webdesignofficina.com
Tue Jul 5 18:33:18 CDT 2005


Hi again,

I'd like to replace an onclick call in my content page.htm as explained 
in a previous mail
<a href="#" onclick="obj.slideTo(0, -200, 1000, -.6); return false;">
The idea is to separate this from the content page.htm, put it in a 
separate .js file and call this using a class="onclick"
Inside the content page the link would then become something like <a 
href="#" class="onclick">
This is the JavaScript i plan to use:

|function onClickSlide() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("onclick")) {
      links[i].onclick = function() {
        |obj.slideTo(0, -200, 1000, -.6);
|        return false;
      }
    }
  }
}
window.onload = ||onClickSlide||;


|

Obviously, this is not working as...

obj.slideTo


...is not a function at all, but an order: onclick > doSomething ( i 
know "order" is not the proper term, sorry )... doSomething resulting 
from 2 other separate scripts...

Should I add the onClickSlide() directly inside the two other scripts ( 
seems not to work either )

Any thoughts ?

Thanks.

Guillaume.
||

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050706/c17331c5/attachment.htm>


More information about the Javascript mailing list