简体   繁体   English

根据iframe网址更改事件采取行动

[英]Act on event of change of iframe url

Okay, so I read and I read, but I couldn't figure out what to do with it. 好的,所以我读了又读了,但是我不知道该怎么做。

My situation is this : A blog is hosted inside my university and is accessible just inside the university. 我的情况是这样的:一个博客托管在我的大学内部,并且可以在该大学内部访问。 That bums me out because I want to check it when I am at home. 这让我很不高兴,因为我想在家时检查一下。 Trust me, if this goes through I will report it to the proper authorities in the university. 相信我,如果一切顺利,我会向大学的有关部门报告。 So what I did was this: I uploaded a PHP script in my webspace in the university which used the webspace offering server(inside the univ domain) to grab the HTML in the blog, and output it to my homepage inside an iframe. 因此,我的工作是这样的:我在大学的网络空间中上传了一个PHP脚本,该脚本使用网络空间提供服务器(在Uniiv域内)在博客中获取HTML,并将其输出到iframe中的我的主页中。

The problem : Whenever I click on any of the links inside the iframe, it redirects to the original page in the blog and so I am not able to read it. 问题:每当我单击iframe内的任何链接时,它都会重定向到博客中的原始页面,因此我无法阅读它。

I started by reading up on addEventListener. 我从阅读addEventListener开始。 Then I thought about outputting the output of the PHP file directly into this page using document.write(). 然后,我考虑使用document.write()将PHP文件的输出直接输出到此页面中。 (But that would cause my original js to disappear, and I don't want that). (但是那会导致我原来的js消失,我不希望那样)。 I saw the multitude of posts announcing the forbidden nature of cross-domain JS access. 我看到许多帖子宣布了跨域JS访问的禁止性质。 So the idea of fetching the URL after I click on the link on the blog inside the ifram and get the 403 forbidden, and then loading the iframe again is gone too. 因此,当我单击ifram内部博客上的链接并禁止使用403,然后再次加载iframe时,获取URL的想法也消失了。

Any suggestion are welcome. 任何建议都欢迎。

Cheers, AJRocker 干杯,AJRocker

我认为这种重定向的原因是,每个链接都具有带有“ _top”值的目标属性,以防止这种注入到iframe中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM