Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    311
    Thanks
    17
    Thanked 0 Times in 0 Posts

    dynamic mouseover by tagName/className

    Hey All, I'm pretty sure this ought to work, but for the life of me I can't figure why it doesn't...
    PHP Code:
    links document.getElementsByTagName('a');
      for (
    i=0;ilinks.length;i++){
      if((
    links[i].className=='listViewThLinkS1')&&(links[i]!='javascript:void(0);')){
        
    alert(links[i]);//returns href values of apropriate 4 links, BUT...
        
    links[i].onmouseover=alert('foo'); // THIS alerts 'foo' onload and then error
      
    }

    WTFO???
    EXAMPLE IN CONTEXT (sort of)
    PHP Code:
    <a href="{ORDER_BY}last_name" class="listViewThLinkS1">{MOD.LBL_LIST_SUBJECT}</a>
    <
    a href="{ORDER_BY}last_name" class="listViewThLinkS1">{MOD.LBL_LIST_CONTACT}</a>
    <
    a href="{ORDER_BY}status" class="listViewThLinkS1">{MOD.LBL_LIST_STATUS}</a>
    <
    a href="{ORDER_BY}date_sent" class="listViewThLinkS1">{MOD.LBL_LIST_DATE_SENT}</a>
    <
    script>
    links document.getElementsByTagName('a');
            for (
    i=0;ilinks.length;i++){
                if((
    links[i].className=='listViewThLinkS1')&&(links[i]!='javascript:void(0);')){
                    
    //alert(links[i]);//alerts the 4 link href values, BUT...
                    
    links[i].onmouseover=alert('foo');//alerts 'foo' one time(though not on mouseover), then error
                
    }
            }
    </script> 
    Last edited by fuzzy1; 08-12-2008 at 07:34 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2006
    Posts
    311
    Thanks
    17
    Thanked 0 Times in 0 Posts
    AHA!
    replacing
    Code:
    links[i].onmouseover=alert('foo');
    WITH...
    Code:
    links[i].onmouseover=function(){alert('foo');};
    WORKS! Though I'm not quite sure why...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •