gpt4 book ai didi

javascript - iframe内容可以改变 "title"页面吗?

转载 作者:行者123 更新时间:2023-11-28 01:57:42 26 4
gpt4 key购买 nike

我有一个带有屏蔽重定向服务的托管服务。

示例

我有这个域名:www.the_domain_whith_redirect.com

并重定向页面:http://www.the_real_path.com/index.html

在浏览器的地址栏中,我读到了“www.the_domain_whith_redirect.com”,但我查看了“http://www.the_real_path.com/index.html”内容

<小时/>

阅读页面源代码,屏蔽的工作原理如下

<html>
<head>
<title>www.the_domain_whith_redirect.com</title>
</head>

<frameset framespacing="0" border="0" rows="0,*" frameborder="0">
<frame name="topmask" src="mask.htm" scrolling="no" noresize>
<frame name="bottommask" src="http://www.the_real_path.com/index.html" scrolling="auto">
</frameset>

</html>

我无法修改此设置,因为我没有对“www.the_domain_whith_redirect.com”域的物理访问权限。这只是一个域。我可以通过我的提供商(Aruba.it)的控制面板修改重定向链接,这才是真正的物理页面。

<小时/>

现在。问题是:

我可以修改“主页面”的标题吗(在此示例中:www.the_domain_whith_redirect.com),通过 Javascript 或通过其他方式,从 iframe 内容?

这是因为浏览器在标题栏中向我显示“www.the_domain_whith_redirect.com”,而不是“您好,这是我的物理站点的真实标题”

<小时/>

谢谢各位的解答

奥斯卡

最佳答案

显然你不能直接更改属性,但你可以调用父页面上的函数来设置父页面的标题。

If your child page (frame1.html) is located at same domain as parent page, and if it is allowed to write a javascript code in the frame1.html, You can call a parent window's function from frame1.html.

In the child page (frame1.html) :

<a href="..." onclick="parent.callFromChildPage()">text</a>

And, In the parent page :

<script language="javascript">
function callFromChildPage(){
$("#test1").html("<h1>clicked</h1>");
}
</script>

And also, if you can use jQuery in the child page (frame1.html), you can set parent page's element directly as follows:

<a href="..." onclick="$('#test1', window.parent.document).html('<h1>clicked</h1>');">text</a>

来源:access and change parent page from iframe (with jquery)

关于javascript - iframe内容可以改变 "title"页面吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18870544/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com