There is a iFrame.. and displayed in that iframe is a certain URL... and outside of that iFrame there is a SKIP/Continue button that is disabled for 10 seconds. After 10 seconds, that button becomes available and when the user clicks it, it changes the webpage displayed in the iFrame to something else, thus disabling the skip button for another 10 seconds. Now, how I have it setup is that the last URL in the array is a script on my site that does an action.. is there an easier way to do this? am i able to POST into my own document using that submit button in order to change a value i have setup?
And you say the last URL is "a script on my site that does an action." But you don't say what action that is and/or show the contents of that last URL.
Not clear why you need the last URL to do what it is doing. Why not just put the equivalent code right in this page, triggered when "Continue" is clicked but there are no more URLs to show?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Works like a charm dude! I can't thank you enough You've helped so much.
Here is my fully developed code (added one line to it to automatically scroll back to top after they click submit
Just ONE more thing though. I attempted to put in a code that detects the length of the page in iframe and automatically adjust the iframe to show the full length, however this code did not work. If you are able to update my code below to do that, it would be freakin amazing
Code:
<iframe id="myframe" width=100% height=1000px></iframe>
<form name="this_form" method="POST" action="">
<input type="submit" name="submit4" value="Submit" onclick="loadNextPage(1)">
</form>
<script type="text/javascript">
var cnt=0,webpageArray = [
"http://cnn.com/",
"http://rapidcashgpt.com/",
"http://codingforums.com"
];
var countDown;
function doCountDown( )
{
var btn = document.this_form.submit4;
if ( countDown <= 0 )
{
btn.value = "Submit";
btn.disabled = false;
return;
}
btn.value = "Submit... " + countDown;
btn.disabled = true;
--countDown;
setTimeout( doCountDown, 1000 );
}
function loadNextPage(dir) {
cnt += dir;
// this can never happen: if (cnt<0) cnt=webpageArray.length-1; // wrap
if (cnt>= webpageArray.length) {
return;
}
var iframe = document.getElementById("myframe");
iframe.src = webpageArray[cnt];
countDown = 10;
doCountDown( );
$('html, body').animate({ scrollTop: 0 }, 'fast');
}
loadNextPage(0); // actually loads first page
</script>
??? I don't see any code in there that attempts to do what you said.
I'm not even sure that it is possible, when the contents of an <iframe> are coming from a foreign site. I think the rules that prevent cross-domain scripting prevent it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
??? I don't see any code in there that attempts to do what you said.
I'm not even sure that it is possible, when the contents of an <iframe> are coming from a foreign site. I think the rules that prevent cross-domain scripting prevent it.
No, i deleted the code because it didnt work. And yes, I'm pretty sure it's possible