在html中获取iframe标题和echo


get iframe title and echo in html


我从地址栏加载我的iframe src,如下所示:
http://site.com/demo.php?go=http://google.com

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<iframe src="<?php echo $_GET["go"];?>">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>


现在我想获得iframe标题,并在demo.php标题标签中回显它…
有可能吗?

请改用JavaScript。像这样:

var iframeTitle = document.getElementById("myIframe").documentElement.title

您需要控制和净化变量'go'。

您可以使用以下类型的函数解析和检索go URI

function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}

然后源CCD_ 3调用CCD_顺便说一句,如果你想把它放在标题标签中,你必须添加这个$('title').val(getURLParameter('go'))(使用jQuery)或纯javascript document.element.getElementsByTagName('title').value = getURLParameter('go')

你应该读一些javascript文档!