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
    New Coder
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation onClick & onDblClick help needed

    Im using this in my web to change menu images OnMouseOver, into common.js:

    Code:
    function roll_images() {
    var default_alt_tag_contents= "Pic";
    var d=document;
    var imgarr = d.getElementsByTagName('img');
    if (imgarr.length>0){
    var imgOriginSrc; var imgTemp= [];
    var ii=imgarr.length;
    while ( ii-- ) { e= imgarr[ii];
    if (!e.getAttribute('alt')) {e.setAttribute('alt',default_alt_tag_contents)}
    if (e.getAttribute('hsrc')) {
    imgTemp[ii] = new Image(); imgTemp[ii].src = e.getAttribute('hsrc');
    if (d.all) { imgarr[ii].style.display= "block";}
    if (d.childNodes && !d.all ) { imgarr[ii].style.overflow= "hidden";}
    e.onmouseover = function() {imgOriginSrc=this.getAttribute('src');this.setAttribute('src',this.getAttribute('hsrc'))}
    e.onmouseout = function() {this.setAttribute('src',imgOriginSrc)}
    }
    }
    }
    }
    function addLoadEvent(func) { var oldonload = window.onload;
    if (typeof window.onload != 'function') { window.onload = func; } 
    else { window.onload = function() { oldonload(); func(); }
    }}
    
    
    
    addLoadEvent(roll_images);
    addLoadEvent(function() {
    
    });
    And something like this to make it work:

    Code:
    	<img src="images/h_news.gif" hsrc="images/h_newsu.gif">
    What i need is to use "OnClick" function in other images, i mean i have some icons in the web and i want when user click the image it changes, when he click it again it back to the first one and go to another page when double click. Can someone help me to do this and add it to my common.js? im so bad with javascript.

    Thanks for advantage.

  • #2
    New Coder
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did it using another .js
    Thnkx anyway.


  •  

    Posting Permissions

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