Jump to content

Need to Stop Javascript Until Needed


NJS

Recommended Posts

Hey there,

 

I've been dabbling with some Javascript and I've been okay adding code in where I wanted until I came to the last part of this executing script. Basically what happens here is the Button Play Flash Game Click Here will pop open a hidden Div that shows places that they can vote at to play the game... Then what I need to happen is after the Vote Click a count down timer pops up to force a 10-15 second wait before the ShowDiv appears.

 

I found that the script immeditately runs once the page is loaded and I have it at a 10second wait, so if I wait 10 second before clicking on anything I'll find that the Div Will Already be shown but if I quickly move through the vote it will take the 10 seconds to appear.

 

So again what I need is for it to start the count down AFTER the vote has been cast. I'm totally newbish when it comes to Javascript I'm just good at creating frankeinsteined code by researching snippits. So please make sure you take it slow with me on this, anything outside the box of copy and paste and it might confuse the hell out of me unless you can explain a tiny bit of whats going on!

 

I appreciate it - here's the code I'm currently using:

 

<script type="text/javascript">
function toggle(obj){
var obj=document.getElementById(obj);
if (obj.style.display == "block") obj.style.display = "none";
else obj.style.display = "block";
}
</script>

<br>
<a href="javascript: void(0);" onClick="toggle('q1')"><center>Play Flash Game Click Here:</center></a>

<div id="q1" style="display:none;"><center>
<a href="javascript:ShowDiv()" onclick=window.open('http://site1.com')>Vote Site #1</a>
<a href="javascript:ShowDiv()" onClick=window.open('http://site2.com')>Vote Site #2</a></div>

<div id="HiddenDiv" style="display:none;"><div id="my_div"></div>

<script type="text/javascript">
(function (){
var element_id = 'my_div' ;
var link_text = '<center>(FLASH GAME CODE EMBEDDED HERE)</center>'; //link code
var time = 10;
setTimeout(function(){document.getElementById(element_id).innerHTML = link_text;},time*1000);
})();
</script></div>

<script language="javascript">
function ShowDiv()
{
document.getElementById("HiddenDiv").style.display = '';
}
</script>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.