iframed version of the site and back button problem

Discussion in 'Javascript' started by zalun, Mar 21, 2006.

  1. zalun

    zalun Guest

    Hi

    I created a site which can be partially iframed (or framed).

    I check if (self == top) and change CSS to turn off some divs.

    The rest of the site which cannot be iframed does top.location =
    self.location and displays content on the top.

    The problem is that when user uses his back button browser stays on the
    non iframed version.
    It is because last page was trying to display part of the site with
    top.location = self.location code.

    Is there any way to avoid this behaviour?
     
    zalun, Mar 21, 2006
    #1
    1. Advertising

  2. zalun

    Randy Webb Guest

    zalun said the following on 3/21/2006 10:28 AM:
    > Hi
    >
    > I created a site which can be partially iframed (or framed).
    >
    > I check if (self == top) and change CSS to turn off some divs.
    >
    > The rest of the site which cannot be iframed does top.location =
    > self.location and displays content on the top.
    >
    > The problem is that when user uses his back button browser stays on the
    > non iframed version.
    > It is because last page was trying to display part of the site with
    > top.location = self.location code.
    >
    > Is there any way to avoid this behaviour?
    >


    top.location.replace(self.location);

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Mar 21, 2006
    #2
    1. Advertising

  3. zalun

    zalun Guest

    After some googling I found a page
    http://www.irt.org/articles/js126/index.htm#5

    One has to change location of the page using following code:

    if (document.images)
    top.location.replace(self.location);
    else
    top.location.href = self.location;
     
    zalun, Mar 21, 2006
    #3
  4. zalun wrote:

    > After some googling I found a page
    > http://www.irt.org/articles/js126/index.htm#5


    OMG. Remove that from your bookmarks. NOW.

    > One has to change location of the page using following code:
    >
    > if (document.images)
    > top.location.replace(self.location);
    > else
    > top.location.href = self.location;


    Utter nonsense. You are testing for one object, but you use another.
    It should be more like

    function isMethod(a)
    {
    if (typeof a == "string") a = eval(a);
    var t;
    return (a && (t = typeof a) == "function" || t == "object");
    }

    var wTop = window.top;
    if (isMethod(wTop.location.replace))
    {
    wTop.location.replace(window.location);
    }
    else
    {
    wTop.location = window.location;
    }

    <URL:http://pointedears.de/scripts/test/whatami>
    <URL:http://jibbering.com/faq/faq_notes/not_browser_detect.html>


    PointedEars
     
    Thomas 'PointedEars' Lahn, Mar 22, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. V Green
    Replies:
    0
    Views:
    885
    V Green
    Feb 5, 2008
  2. PA Bear [MS MVP]
    Replies:
    0
    Views:
    1,000
    PA Bear [MS MVP]
    Feb 5, 2008
  3. Robert Oschler
    Replies:
    0
    Views:
    88
    Robert Oschler
    Sep 6, 2005
  4. Replies:
    5
    Views:
    115
    shimmyshack
    Jun 27, 2007
  5. Sharkie
    Replies:
    2
    Views:
    81
    Sharkie
    May 27, 2008
Loading...

Share This Page