我想在我的iframe中打印父网址。可能吗?

时间:2014-12-16 10:43:07

标签: javascript iframe

我想在iframe中打印父域名。可能吗?分享你的想法。提前致谢。 :)

enter image description here

父页

<html><head><title></title></head>
<frameset border="0" rows="100%,*" cols="100%" frameborder="no">
<frame name="TopFrame" scrolling="yes" noresize src="http://test.com/test.php">
<frame name="BottomFrame" scrolling="no" noresize></frameset>
</html>

iframe页面(test.php)

<body>
<h1 align="center">Parent Domain Name</h1>
</body>

1 个答案:

答案 0 :(得分:0)

您可以将您喜欢的任何值传递给PHP页面,然后在框架视图中输出它吗?

<frame name="TopFrame" scrolling="yes" noresize src="http://test.com/test.php?domain=mydomain.com">

然后在test.php

<h1 align="center"><?php echo $_GET['domain']; ?></h1>

可替换地,

您也可以尝试使用putvande提到的window.parent.document.location.href JavaScript。然后使用document.writeln或jQuery将值添加到页面。您可以使用以下内容获取域名:window.parent.document.location.href.split("/")[2]

相关问题