SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mozilla's iframe back button

    Hello, can anyone tell me why code doesn't work in Mozilla using location.replace? I'm rotating content in an iframe and I'm trying to make it so when the user clicks on the back button they can leave the page as normal. Right now they are stuck on the page when they click on the back button, because the history is reading the iframe content instead of the page before. Please let me know why location replace doesn't work in Mozilla an if there there are any work arounds. Thank you very much.

    i=0;
    function rotateframe(){
    document.arr.location.replace(arr[i]);
    i++;
    setTimeout('rotateframe()',3000)}

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using window.frames['arr'] instead of document.arr.

    Reasons to Avoid Frames and iFrames
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not working, I tried this window.frames(arr[i]);
    Thanks.

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're going to have to show us more of your code.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You bet, here it is.
    <script type="text/javascript">
    var arr = new Array(
    ["http://www.tinypic.com"],
    ["http://www.google.com"],
    ["http://www.yahoo.com"]// no comma at end
    );

    i=0;
    function rotate(){
    document.arr.location.replace(arr[i]);
    i++;
    setTimeout('rotate()',3000)}
    </script>
    And for the body
    <BODY onload="rotate();">
    <iframe name="arr" src="" width="300" height="300" marginwidth="0"
    marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why the square brackets around the strings in the array? (In that context the brackets are array literals.)

    Why window.frames[] didn't work is because you named the frame the same thing as your array.

    Don't forget to make sure that the (X)HTML and CSS code you write is valid.
    http://validator.w3.org/
    http://jigsaw.w3.org/css-validator/
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, how does the rotating content get added to the iframe if it doesn't have the same id or name?

    I tried this.
    <script type="text/javascript">
    var arr = new Array();
    arr[0]="http://www.yahoo.com";
    arr[1]="http://www.google.com";
    arr[2]="http://www.yahoo.com";
    i = 0;
    function rotate()
    {
    window.frames(arr[i]);
    i++; if (i == arr.length)
    {i = 0; } setTimeout('rotate()', 5000)}
    </script>
    using "arr" as the iframe id or name. Either way I get this error
    "object doesn't support this action window.frames(arr[i]);"


Bookmarks

Posting Permissions

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