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

Button doing two things including delay

Discussion in 'HTML & JavaScript' started by darkface, Apr 25, 2010.

  1. darkface

    darkface Senior Member

    Oct 8, 2009
    Likes Received:
    Hey guys, I could need some help,

    so basically I have a button that when clicked, opens another window with a different page. Now I want that when that button is clicked it doesn't only open another window but that in the window the button is clicked in, 7 seconds after it has been clicked, some text appears.

    So basically user clicks button, other page appearrs, 7 seconds later in the first one some text also appears.

    I just can't seem to get it to work. Giving rep and thanks = )
  2. voyevoda

    voyevoda Regular Member Premium Member

    Mar 21, 2010
    Likes Received:
    Eastern Front
    Add an onclick attribute to the hyperlink that calls setTimeout(). Pass it a function or some code that replaces the link with your desired text.


    <a href="other_page_here" target="_blank" onclick="setTimeout('your javascript to add the text here', 7000); return true;">your anchor text</a>
    If it's a true "button" (that is, an <input> element), then just add the onclick attribute from above to the button instead. You could also add it as an onsubmit attribute to the <form>.
    • Thanks Thanks x 2