javascript iframe “top.” multiple divs?

佐手、 提交于 2019-12-13 07:32:53

问题


I orginally asked this question and at the time I was grasping at straws. I created the following fiddle that is closely related to what I'm actually seeing on my internal application:

http://jsfiddle.net/uwtj9/10/

There is a normal index.asp page. On that page I can open a div that includes an iFrame (so a popup). Then from that iFrame I can then open another div that includes another iFrame. However, when the second div opens I am trying to close the 1st div. Hopefully that makes sense.

However, when I try to open the second div, the code to create the iframe never gets run. I think it has to do with the "top." that is currently in my internal application code. When I try to add top.hidepopwin I get an error in Firebug: Permission denied to access property 'hidePopWin'

However, in my code internally I don't get that error message, but I don't get into the doPopWin code.

Unfortunately for whatever reason when I take out the top. in my code internally it doesn't quite work the way I'm expecting (and I can't replicate it on the fiddle). Basically the second div gets created but it remains the same size and not all the elements are getting cleared (i.e the original menu is still showing up under the new menu).

Anyone have any idea's on this? The fiddle seems to be working as I expect but this "top." thing is kind of weird.

UPDATE:

SLaks answer of why the "top." doesn't work for jsFiddle is acceptable. I'm still left wondering about this issue:

Unfortunately for whatever reason when I take out the top. in my code internally it doesn't quite work the way I'm expecting (and I can't replicate it on the fiddle). Basically the second div gets created but it remains the same size and not all the elements are getting cleared (i.e the original menu is still showing up under the new menu).

Any ideas?


回答1:


top returns the window object for the outermost frame hosting your page.

In jsFiddle, that's the root jsfiddle.com page, which is in a different domain than your user code. (user submissions in jsFiddle run in http://fiddle.jshell.net)



来源:https://stackoverflow.com/questions/7923601/javascript-iframe-top-multiple-divs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!