views:

45

answers:

2

Hi,

i have a website which uses top in javascript to show bookshops in a panel. Now i want to add this website into another website using a frame. But when i fix the url in the src of the frame , it changes the hierarchy of the pages or images and the bookshops are not shown.

Can anybody sugget me the solution for this.

Khushi

A: 

So "top" is actually "window.top" (but since window is part of the global scope you can get away with just "top"). If you read up on what window.top does, you'll discover that it returns "a reference to the topmost window in the window hierarchy". In other words, if you have:

Frame Page B
  Famed Page C

and you invoke window.top from either one, you'll get the same window object back (the one for page B).

However, if you instead have:

Frame Page A
  Frame Page B
    Famed Page C

window.top will always return the window object for page A, whether you call it from A, B, or C.

What I think you want to use instead (although it's hard to know without seeing your site) is window.parent (ie. "parent" if you don't want to bother with "window."). This property returns the immediate parent of the window in question. If you invoke this from C, it will ALWAYS return B's window, even if B is framed inside A. This should allow you to frame your (framing) page however you want, without messing up the logic of the innermost frame.

Hope that helps.

machineghost
A: 

I'm not sure if i really understand your problem. (o;

This should be a simple form of the default frameset of your site.

<html>
    <frameset rows="50,50">
     <frame name="bookframe" src="bookframe.html" />
     <frame src="default.html" />
    </frameset>
</html>

And this should be the default.html with the javascript code to control the bookframe panel.

<html>
    <body>
     <script>
      parent.frames["bookframe"].location.href  = "uri";
     </script>
    </body>
</html>

As you can see, i'm using the name of the frame instead of top.

Include the framset from my first listing into a new page using an iframe and everythings is still working.

<html>
    <body>
     <iframe src="frameset.html" />
    </body>
</html>

If your website from the beginning uses just an iframe instead of a frameset, it is still working by using the name instead of top.

HINT: the name should be unique. there should be no javascript variable with the same name. only microsoft ie knows why!

hope that helps!

michl86