Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Funny problem with frames in browser opened in new window. 2

Status
Not open for further replies.

emwufwe

Programmer
Jan 22, 2003
2
SE
I have a php-driven web application that uses a frameset with 4 frames: left, right, header and footer. The left frame contains an explorer-like tree with links to pages that are opened in the right frame.


My problem occurs when I do this procedure:

- I right-click on a link in the tree and selects "Open in New Window". The page that are normally opened in the right frame is then opened alone in a new browser window.

- In the new browser I type in the URL to the whole application. It is then opened in the new browser with all 4 frames.

- Every time I click on a link in the tree in the left frame of the new browser, the links page is opened in the whole browser instead of just the right frame, as if I had selected "Open in New Window".


My question is: How come the frameset doesn't work in the browser opened from the link in the original browser?
I have noticed that the new browser doesn't get an own IEXPLORE.EXE process in the task manager. It seems as if it's only a new thread in the original browsers process. Can that have anything to do with the strange frame behavior?

Thanks in advance!
 
If you post a link to the code we can take a quick look. First impressions though... are you naming the frames left, right etc? If so... are you targetting the frames correctly from the a href (ie. <a href="something" target="right">xxx</a>)?

Regarding a new link not spawning a new IEXPLORER process... that is indeed correct... any windows opened off another window share the same session and process (so if you kill off the one process all siblings are also killed).

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Hi Jeff,

I would like to show you the whole code, but it's a rather complex PHP application that is intended to run embedded in a device with its own web server. It cannot execute outside this device without a simulator, so you cannot "test drive" it.

However, I wrote some simple test html pages to reproduce the problem, which was quite easy.

The page "frametest.html"
contains the same frame structure as my application. When loaded, it opens the page "left_framepage.html" in its left frame and my favorite site IMDB in the right frame.

The page "left_framepage.html" has a link to the page "right_framepage.html" that only outputs the text "Right frame". When this link is clicked, the IMDB page is replaced with "right_framepage.html" in the right frame.

To see the frame problem: Right-click on the link in the left frame and select "Open in New Window". In the new window: Type the URL to the page "frametest.html". Then left-click on the link in the left frame and you'll se the output of "right_framepage.html" in the whole browser instead of in the right frame. Funny, huh? If you can explain why, I'll be grateful.

Can it be that the new browser window somehow inherits the name or ID of the right frame, and therefore connects the main window with target="right"?
If so, is there a workaround?

The HTML test pages looks like...

File: frametest.html
Code:
<html>

<head>
</head>

<frameset border="2" frameborder="0" framespacing="2" rows="50,*,17">
    <frameset border="0" frameborder="0" framespacing="2" cols="*,100">

      <frame name="top" scrolling="no" noresize target="header" src="top_framepage.html" marginwidth="0" marginheight="0">
    </frameset>
 
    <frameset border="2" frameborder="1" framespacing="4" cols="200,*">
      <frame name="left" src="left_framepage.html" marginwidth="0" marginheight="0">

      <frame name="right" src="[URL unfurl="true"]http://www.imdb.com"[/URL] marginwidth="0" marginheight="0" frameborder="0">
     
    </frameset>
    <frame name="footer" scrolling="no" noresize target="contents" src="footer_framepage.html" marginwidth="0" marginheight="0">
  </frameset>

</html>

File left_framepage.html:
Code:
<html>
<body>
Left frame
<br>

<a href="right_framepage.html" target="right">Start page in right frame</a>
</body>

</html>

File right_framepage.html:
Code:
<html>
  <body>
  Right frame
  </body>
</html>

File top_framepage.html:
Code:
<html>
  <body>
  Top frame
  </body>
</html>

File footer_framepage.html:
Code:
<html>
  <body>
  Footer frame
  </body>
</html>
 
OK... now I have a much better understanding of your problem. This problem is only visible in IE (not in FF or Opera) on Windows.

So... my explaination is...

When you right click the link and open it in a new window, it appears that IE is naming that window to be the name of the target in that URL (let's keep using the term "name" even though it may not be quite correct).

This leaves us with a window with the name "right" and another window with a frameset that contains a frame named "right".

If you flick back to the original frameset, you can continue using the left nav and it will correctly target the "right" frameset (in the original window). You are only seeing odd things happen when you use the newly created window (after you have then typed the original frameset back into it).

I would suggest that you run some javascript once a frame document (not a frameset document) has loaded and test that the correct frameset arrangement is wrapping your page. Effectively doing the opposite of "frame busting".

Does this make some kind of sense to you?

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
After some tinkering, I've figured out what's going on. You can use [tt]target[/tt] attributes to address whole browser windows as well as frames. You can use this to your advantage when re-using windows that might already be open, e.g. always linking to a pop-up help screen using [tt]target="help"[/tt] to prevent proliferation of different help windows.

So when you shift-click on a framed link that has a [tt]target="left"[/tt] attribute so it opens in a new window, IE names the whole window "left". Subsequent links within that window that have a [tt]target="left"[/tt] are loaded into the whole window, rather than into a frame with that name.

The naming-window-on-shift-click behaviour is probably a bug in IE. FF doesn't work that way, I didn't try anything else. If you think your visitors are likely to do this, it's (another) disadvantage of using frames, albeit a pretty obscure one.

If this is an issue, I suggest you don't use frames; but then I'd always suggest that anyway...

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top