SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    back,forward browser button for iframe

    I am wondering how Back, Forward browser button works for iframes. Does it bring back/forward iframe or top window?

    I remember I had before a problem because I wanted to bring back iframe and not top window as it did. But today I tested my Facebook app and was surprised to see it works as I need which means it brings back/forward iframe window and not top. Is it possible that Facebook has some javascript code which does that or is this normall behaviour?

    Thank you

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,893
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Usually the back button will cycle back through the various links loaded in the <iframe>, and then back to the previous page once you've reached the first link loaded in the <iframe>, but I don't know if this behaviour is mandated or whether browsers are free to choose whatever model they like.

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,401
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meee View Post
    I am wondering how Back, Forward browser button works for iframes. Does it bring back/forward iframe or top window?

    I remember I had before a problem because I wanted to bring back iframe and not top window as it did. But today I tested my Facebook app and was surprised to see it works as I need which means it brings back/forward iframe window and not top. Is it possible that Facebook has some javascript code which does that or is this normall behaviour?

    Thank you
    Perfect timing, I'm having an issue on this one as well. No, facebook does not have any special script to allow iframe back/forward. It's built-in browser functionality. For me, my problem lies in multiple iframe's history. Apparently..at least for Firefox..it has no problem handling just 1 iframe for back/forward.... but when it comes to "multiple" iframe..then it acts very weird!

    you can do this in javascript by

    window.frames['frameA'].history.go(-1);

    from above code, it makes you "think" you're using "iframe's" history but it's really not...


    See my post for more details...

    http://www.sitepoint.com/forums/showthread.php?t=730295

    Help Plz!!!

  4. #4
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Most browser built in buttons won't work. You need to right click within the frame to control it. Why do yo need to go back? you may be able to use JS to control the iframe from the main.
    Ryan B | My Blog | Twitter

  5. #5
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,401
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    Most browser built in buttons won't work. You need to right click within the frame to control it. Why do yo need to go back? you may be able to use JS to control the iframe from the main.
    That's what I thought too.. maybe it's specific to firefox browser. I was able to get specific reference to multiple iframes on the page... however they all shared the same "history" reference..

    for example

    window.frames['frameA'].history === window.frames['frameB'].history

    so if I browse a bit from frameA and frameB and run

    window.frames['frameA'].history.go(-1)
    window.frames['frameA'].history.go(-1)
    window.frames['frameA'].history.go(-1)

    eventually..it'll perform "back" on 'frameB' as well.... at this stage..I'm leaning toward a bug in firefox... wish I was proven wrong.


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
  •