1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

do you know why this js code snippet doesnt work?

Discussion in 'Black Hat SEO' started by Rushdie, Jan 11, 2012.

  1. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    hey,

    i need to open a link (actually it will be a lightbox later) a few seconds after the page loads. can you tell me why this test code doesnt work? thanks

    Code:
    <head>
    
     <script type="text/javascript">
      function pop_up_light_box()
      {
    	document.getElementById('light').style.display='block';
      }
     
      function pop_up_light_box_with_delay(secs)
      {
    	setTimeout('pop_up_light_box()',secs*1000);
      }
      </script>
      
    </head>
    
    <body onLoad="pop_up_light_box_with_delay(3);">
    <a href=google.com id="light">google</a>
    </body>
     
  2. blancog76

    blancog76 Registered Member

    Joined:
    Jun 25, 2011
    Messages:
    74
    Likes Received:
    16
    Occupation:
    Mad Coder
    if you are using jquery lightbox then why not use the events model in jquery as opposed to the older style onload of the body?
     
  3. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    actually im using lytebox cause i open iframes and it works nice with those and im not sure how to do it
     
  4. infTee

    infTee Junior Member

    Joined:
    Mar 2, 2010
    Messages:
    101
    Likes Received:
    97
    Location:
    Ireland
    Is the problem that the 'light' element is shown immediately and not delayed? If so just change it to this:
    Code:
    <head>
    
     <script type="text/javascript">
      function pop_up_light_box()
      {
    	document.getElementById('light').style.display='block';
      }
     
      function pop_up_light_box_with_delay(secs)
      {
    	setTimeout('pop_up_light_box()',secs*1000);
      }
      </script>
      
    </head>
    
    <body onLoad="pop_up_light_box_with_delay(3);">
    <a href=google.com id="light" style="display:none">google</a>
    </body>
    The only difference is that it is set to be hidden initially with the style tag in there.
     
    • Thanks Thanks x 1
  5. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    thanks, maybe you can help me more.

    i want to activate this with a delay after loading the page (its o popup)

    what method do i need to use?

    Code:
    <a href="1.html" id="light" class="lytebox" data-lyte-options="width:1020 height:2300 scrollbars:yes"><img src=http://......png border=0></a>
     
  6. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    i did it with jquery, thanks