iframe问题与window.top有关 [英] Iframe issue with window.top

查看:820
本文介绍了iframe问题与window.top有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET网站,我在其中嵌入了iframe并在其中打开了第三方网站,即我没有该网站的控件。现在该网站在许多地方使用带有window.top的javascript来访问元素,例如:

I have an ASP.NET website in which I embedded an iframe inside a page and open a third party website inside it, i.e. I do not have a control on that website. Now that website uses a javascript with "window.top" at many places to access elements, like:

window.top.$('#elementid')...



问题是网站在iframe中打开,第三方网站内的顶部是指最顶层的浏览器窗口,这是我的网站页面,而不是他们的网站。所以它不会获得它使用的id元素。所以它抛出了javascript错误而没有正确加载。当我在新标签页面中打开该网站时,它正确加载。



您能否为我提供解决方案,使顶部引用iframe本身?



我尝试了什么:



使用window.self可以解决问题,但我无法修改第三方网站的javascript。所以我需要一些其他解决方案。该网站也必须仅显示在我的网站页面内。


The problem is as the website is opened in an iframe, "top" inside third party website refers to topmost browser window which is my website page, and not their website. So it will not get elements with id it uses. And so it throws javascript errors and not loaded correctly. When I open that website in new tab, it loads correctly.

Can you provide me the solution to make "top" refer to the iframe itself?

What I have tried:

Using "window.self" can resolve the problem, but I cannot modify javascript of third-party website. So I need some other solution. Also that website must be displayed inside my website page only.

推荐答案

('#elementid')...
('#elementid')...



问题是网站在iframe中打开,第三方网站内的顶部是指最顶层的浏览器窗口,这是我的网站页面,而不是他们的网站。所以它不会获得它使用的id元素。所以它抛出了javascript错误而没有正确加载。当我在新标签页面中打开该网站时,它正确加载。



您能否为我提供解决方案,使顶部引用iframe本身?



我尝试了什么:



使用window.self可以解决问题,但我无法修改第三方网站的javascript。所以我需要一些其他解决方案。此网站也必须仅显示在我的网站页面内。


The problem is as the website is opened in an iframe, "top" inside third party website refers to topmost browser window which is my website page, and not their website. So it will not get elements with id it uses. And so it throws javascript errors and not loaded correctly. When I open that website in new tab, it loads correctly.

Can you provide me the solution to make "top" refer to the iframe itself?

What I have tried:

Using "window.self" can resolve the problem, but I cannot modify javascript of third-party website. So I need some other solution. Also that website must be displayed inside my website page only.


包括第三方网站在内的法律问题,不仅仅是因为他们创建了一个直接在浏览器窗口中托管的网页而不是其他任何东西......
Including 3rd party website has legal problems to, not only the fact, that they created a web page to be hosted directly in browsers window and not by anything else...


这篇关于iframe问题与window.top有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆