对 iframe url 更改事件采取行动
好吧,我读了又读,但我不知道该怎么办。
我的情况是这样的: 我的大学内托管着一个博客,并且可以在大学内访问。 这让我很烦恼,因为我想在家时检查一下。相信我,如果此事成功,我会向大学有关当局报告。 所以我所做的是:我在大学的网络空间中上传了一个 PHP 脚本,该脚本使用网络空间提供服务器(在 univ 域内)来获取博客中的 HTML,并将其输出到 iframe 内的我的主页。
问题 : 每当我单击 iframe 内的任何链接时,它都会重定向到博客中的原始页面,因此我无法阅读它。
我首先阅读了 addEventListener。然后我想到使用document.write()将PHP文件的输出直接输出到这个页面中。 (但这会导致我原来的js消失,我不希望这样)。我看到很多帖子都宣布禁止跨域JS访问。因此,在我点击 iram 内博客上的链接并收到 403 禁止后获取 URL,然后再次加载 iframe 的想法也消失了。
欢迎任何建议。
干杯, AJ摇杆
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.
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.
I started by reading up on addEventListener. Then I thought about outputting the output of the PHP file directly into this page using document.write(). (But that would cause my original js to disappear, and I don't want that). I saw the multitude of posts announcing the forbidden nature of cross-domain JS access. 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.
Any suggestion are welcome.
Cheers,
AJRocker
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这种重定向的原因是每个链接都有带有“_top”值的目标属性,以防止这种注入 iframe 的情况。
I think the reason of that kind of redirecting is that every link has the target attribute with "_top" value to prevent this kind of injection into iframes.