对 iframe url 更改事件采取行动

发布于 2024-12-19 09:12:51 字数 478 浏览 0 评论 0原文

好吧,我读了又读,但我不知道该怎么办。

我的情况是这样的: 我的大学内托管着一个博客,并且可以在大学内访问。 这让我很烦恼,因为我想在家时检查一下。相信我,如果此事成功,我会向大学有关当局报告。 所以我所做的是:我在大学的网络空间中上传了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹂绝世的画 2024-12-26 09:12:51

我认为这种重定向的原因是每个链接都有带有“_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文