View Single Post
Old 10-05-2012, 03:15 AM   PM User | #11
markman641
Regular Coder

 
Join Date: Jul 2011
Posts: 246
Thanks: 58
Thanked 1 Time in 1 Post
markman641 has a little shameless behaviour in the past
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>
markman641 is offline   Reply With Quote