tags:

views:

38

answers:

1

Hi everyone!

I was making a page with frames. One is a treeview frame, the other is showing a report. When I click the item in the left frame, the report will display in the right frame. But after I click the first item, the location object in the right frame became unavailable! Which prevents me from opening a new report in the same frame! Below is the main page code:

<iframe src ="demoFramesetLeftFrame.jsp" name="treeframe" id="treeframe" height="100%" width="200px" frameborder="0">
<iframe src="demoFramesetRightFrame.jsp" name="basefrm" id="basefrm" height="100%" width="" frameborder="0">

The basefrm is response for displaying the report. Does anyone know how to solve this? Thanks a million!

A: 

It sounds like the navigation from the left frame is taking the right frame to a page on a different hostname. Then the right frame's window properties including location are inaccessible to code in the parent page due to the Same origin policy.

You can still navigate a frame without using its window's location object. Just set the src attribute on the iframe object itself (in the parent document).

(Also consider not using frames for navigation like this. You'll be making your separate reports unbookmarkable.)

bobince
thank you bobince! Yes,the left frame is taking the right frame on a different hostname.but i have tested set the <code>src<code> attribute,it doesn't work.the right frame don't display the report at all.Is there another way to do this?
huangli
Setting `src` works fine for me, even on a frame that is currently displaying a document from a different domain. An alternative to allow navigation to still work if you don't have access to the report documents would be to have a series of pages, eg. `/report.php?report=1`, `/report.php?report=2`, each of which contains an `<iframe>` pointed at a single report, plus normal nav to go to the different parent documents.
bobince
Thanks bobince!it worked!Setting src works correctly!
huangli