【问题标题】:I want to print parent url in my iframe. Is it possible?我想在我的 iframe 中打印父 url。是否可以?
【发布时间】:2014-12-16 10:43:06
【问题描述】:

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

父页面

<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>

【问题讨论】:

标签: javascript iframe


【解决方案1】:

您可以将任何您喜欢的值传递给 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]

【讨论】:

    猜你喜欢
    • 2011-01-12
    • 2022-07-26
    • 2020-06-16
    • 1970-01-01
    • 2022-12-06
    • 1970-01-01
    • 2014-04-17
    相关资源
    最近更新 更多