SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascipt Timer Help

    I need to create a timer that closes a modal box and then jumps the url that was clicked on in the html.

    What would be the best way to execute this?

  2. #2
    SitePoint Enthusiast TriLLi's Avatar
    Join Date
    Feb 2010
    Location
    BiH, Bugojno
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    add attribute rel to a links, for example rel="open_modal" then
    Code JavaScript:
    var links = document.getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)
    {
      if(links[i].getAttribute('rel') == 'open_modal')
      {
        links[i].onclick = function()
        {
            //code for open modal
            var hrf = this.getAttribute('href');
            setTimeout(function() { 
                //code for close modal
                window.open(hrf, 'mywin', '_self');
           }, 5000);
            return false;
        }
      }
    }

    i hope this helps, if you use jQuery you can do this much easier, when I say much easier I mean with less code


Bookmarks

Posting Permissions

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