Multiple onClicks events aren't working together

Discussion in 'JavaScript' started by andysm849, Feb 13, 2009.

  1. #1
    I have a simple javascript overlay (like a lightbox) with a message that pops up. The user is meant to click a button, see the overlay thanking them for their vote, and then be redirected to the affiliate page (its a poll site) after about 3 seconds. I have everything down, except, it will either display the overlay as one of the onClick events, or it will do the timedRedirect but not both. I've tried putting the redirect before and after, and when its before it redirects, when its after, it shows the overlay. How can I do a timed redirect and show this message?

    <script type="text/JavaScript">
    <!--
    redirectTime = "3500";
    redirectURL = "http://x.azjmp.com/2KTCs";
    function timedRedirect() {
    	setTimeout("location.href = redirectURL;",redirectTime);
    }
    //   -->
    </script>
    
    <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"; "timedRedirect()"; > 
    
    <img class="alignleft" title="no" src="http://www.pollquick.net/no.jpg" alt="" width="260" height="74" /></a><div id="light" class="white_content" >Thank you for your input! Follow the directions on the next page to submit your vote.
     <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">.</a></div> <div id="fade" class="black_overlay"></div> </div> 
    Code (markup):

     
    andysm849, Feb 13, 2009 IP
  2. yoavmatchulsky

    yoavmatchulsky Member

    Messages:
    57
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    <script type="text/JavaScript">
    <!--
    redirectTime = "3500";
    redirectURL = "http://x.azjmp.com/2KTCs";
    function timedRedirect() {
    	setTimeout("location.href = redirectURL;",redirectTime);
    }
    //   -->
    </script>
    
    <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'; timedRedirect()"; > 
    
    <img class="alignleft" title="no" src="http://www.pollquick.net/no.jpg" alt="" width="260" height="74" /></a><div id="light" class="white_content" >Thank you for your input! Follow the directions on the next page to submit your vote.
     <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">.</a></div> <div id="fade" class="black_overlay"></div> </div> 
    Code (markup):
    you can't close the onclick quotation mark and reopen it..
     
    yoavmatchulsky, Feb 14, 2009 IP
    andysm849 likes this.
  3. andysm849

    andysm849 Peon

    Messages:
    198
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How did I miss that?? It seems so obvious now! Thanks a bunch.
     
    andysm849, Feb 14, 2009 IP