Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    Which code isn't working in FF? Exactly what is in your post #11 or something different?
    I'll get you the code. Firefox is reloading the page. You can see it here: http://www.QuizBonanza.com/campaigns/iframe.php


    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)"></button>
    </form>
    <?
    $link = mysql_connect('localhost', 'ad20_ad20', 'xxxxxxxx');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    $db_selected = mysql_select_db('xxxxxxx', $link);
    if (!$db_selected) {
        die ('Can\'t use foo : ' . mysql_error());
    }
    ?>
    <script type="text/javascript">
          var cnt=0,webpageArray = [<?php
    $query = "SELECT URL FROM path where campaigns LIKE '%$currentFile%'";
    $result = mysql_query($query) or die( mysql_error() );
    $delimiter = "";
    while ( $row = mysql_fetch_array($result) )
    {
        echo $delimiter . '"' . $row[0]. 'UNIQUEID' . '"' ;
        $delimiter = ",\n";
    }
    ?>]; 
          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>
    Last edited by markman641; 10-29-2012 at 03:15 AM.

  2. #17
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    You messed up.

    Code:
    <form name="this_form" method="POST" action="">
    <input type="submit" name="submit4" value="Submit" onclick="loadNextPage(1)"></button>
    </form>
    First of all, that is ILLEGAL HTML. So who knows what the various browsers will do with illegal html?

    You have a </button> tag but *NO* matching <button> tag.

    But more than that...

    Because that button is a SUBMIT BUTTON, when the loadNextPage function returns, the button GOES AHEAD AND SUBMITS THE <FORM>!!!!
    FireFox is doing the *right* thing. I have no idea why Chrome doesn't act the same way.

    **********

    Two simple answers:

    (1) Make sure you return false from the onclick:
    Code:
    <form name="this_form" method="get" action=""><!-- or omit the method -->
    <input type="submit" name="submit4" value="Submit" onclick="loadNextPage(1);return false">
    </form>
    Simpler answer: Don't use a submit button:
    Code:
    <form name="this_form" method="get" action=""><!-- or omit the method -->
    <input type="button" value="Submit" onclick="loadNextPage(1);">
    </form>
    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.

  3. Users who have thanked Old Pedant for this post:

    markman641 (11-03-2012)

  4. #18
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    You messed up.

    Code:
    <form name="this_form" method="POST" action="">
    <input type="submit" name="submit4" value="Submit" onclick="loadNextPage(1)"></button>
    </form>
    First of all, that is ILLEGAL HTML. So who knows what the various browsers will do with illegal html?

    You have a </button> tag but *NO* matching <button> tag.

    But more than that...

    Because that button is a SUBMIT BUTTON, when the loadNextPage function returns, the button GOES AHEAD AND SUBMITS THE <FORM>!!!!
    FireFox is doing the *right* thing. I have no idea why Chrome doesn't act the same way.

    **********

    Two simple answers:

    (1) Make sure you return false from the onclick:
    Code:
    <form name="this_form" method="get" action=""><!-- or omit the method -->
    <input type="submit" name="submit4" value="Submit" onclick="loadNextPage(1);return false">
    </form>
    Simpler answer: Don't use a submit button:
    Code:
    <form name="this_form" method="get" action=""><!-- or omit the method -->
    <input type="button" value="Submit" onclick="loadNextPage(1);">
    </form>
    It's SUPPOSED to submit the form after the last one. Also doing that completely breaks the 10 seconds disabled thing.
    Last edited by markman641; 10-30-2012 at 11:07 PM.

  5. #19
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    What does "after the last one" mean?

    If you submit the <form>, it *WILL* rebuild the ENTIRE page, and so any change to the <iframe> *WILL* be lost. You have no choice on that.
    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.

  6. #20
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    What does "after the last one" mean?

    If you submit the <form>, it *WILL* rebuild the ENTIRE page, and so any change to the <iframe> *WILL* be lost. You have no choice on that.
    What I mean by "after the last one" is that it shows the x amount of websites in the iframe, and then when the user gets to the last one and clicks continue it ACTUALLY submits for form. It's supposed to do this so that I can move the user on to the next part of the registration process. This is exactly what chrome does.
    Last edited by markman641; 10-31-2012 at 01:25 AM.

  7. #21
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    Well, you have zero code in there doing that, so far as I can see. So I haven't the foggiest idea why it works in Chrome.

    You could, however, easily fix the code:
    Code:
        function loadNextPage(dir) {   
            cnt += dir;
            // this can never happen: if (cnt<0) cnt=webpageArray.length-1; // wrap
            
            if (cnt>= webpageArray.length) {
                return true;
            } 
            var iframe = document.getElementById("myframe"); 
            iframe.src = webpageArray[cnt]; 
            countDown = 10;
            doCountDown( );
            $('html, body').animate({ scrollTop: 0 }, 'fast');
            return false;
        }
    And then:
    Code:
    <input type="submit" name="submit4" value="Submit" onclick="return loadNextPage(1);">
    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.

  8. Users who have thanked Old Pedant for this post:

    markman641 (11-03-2012)

  9. #22
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    Well, you have zero code in there doing that, so far as I can see. So I haven't the foggiest idea why it works in Chrome.

    You could, however, easily fix the code:
    Code:
        function loadNextPage(dir) {   
            cnt += dir;
            // this can never happen: if (cnt<0) cnt=webpageArray.length-1; // wrap
            
            if (cnt>= webpageArray.length) {
                return true;
            } 
            var iframe = document.getElementById("myframe"); 
            iframe.src = webpageArray[cnt]; 
            countDown = 10;
            doCountDown( );
            $('html, body').animate({ scrollTop: 0 }, 'fast');
            return false;
        }
    And then:
    Code:
    <input type="submit" name="submit4" value="Submit" onclick="return loadNextPage(1);">
    Unfortunately firefox is still refreshing the page. Works in chrome still though.

  10. #23
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    *SIGH*

    You know why?

    Because your code ends with:
    Code:
        $('html, body').animate({ scrollTop: 0 }, 'fast');
        return false;
    }
    That is, you are invoking a jQuery function to do the animate, right?

    BUT YOU DO NOT HAVE THE jQUERY LIBRARY LOADED on that page!!!!!!!!!

    So the animate line gets an *ERROR* and the function exits on the error.
    And when it exits on error there is only 1 chance in 4 billion that it will return false.

    So it is returning true, because of the error, and thus allowing the submit to proceed.
    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.

  11. Users who have thanked Old Pedant for this post:

    markman641 (11-03-2012)

  12. #24
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    When I cloned your code and simply commented out the animate line, it worked in FF as you wanted.
    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.

  13. Users who have thanked Old Pedant for this post:

    markman641 (11-03-2012)

  14. #25
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Thanks so much dude! I called the jQuery script and it worked like a charm!


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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