Php Iframe到其他web端
我不能去其他网站位于不同的领域Php Iframe到其他web端,php,html,iframe,href,Php,Html,Iframe,Href,我不能去其他网站位于不同的领域 echo "<b>Enter your page:</b> <br> <form action='iframe.php' method='get'> <input type='text' name='www' size='50' value='https://'> <input type='submit' value='Go to!'> </form>
echo "<b>Enter your page:</b> <br>
<form action='iframe.php' method='get'>
<input type='text' name='www' size='50' value='https://'>
<input type='submit' value='Go to!'>
</form>
<br>";
echo "<iframe width='80%' height='80%' src=" ;
if(!isset($_GET['www'])){
echo "www.google.com>";
}
else{
echo "".$_GET['www'].">";
}
echo“进入您的页面:
“;
回声“;
}
否则{
echo.“$”\u GET['www']。“>”;
}
您知道如何修复它吗?我不建议使用
iframe
(在我看来,这是一个非常难看的问题),但我已经测试了以下代码(JavaScript、HTML和PHP),它似乎可以工作。在你的原始代码中,你引用谷歌时没有任何http
或https
前缀,但当我(为另一个网站)测试它时,它似乎起作用了
无论如何,你可能想试试我的方法:
PHP:
<?php
if(isset($_GET['www'])) {
$url = $_GET['www'];
} else {
$url = 'https://www.google.com/';
}
?>
<strong>Enter URL:</strong>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="text" name="www" size="50" placeholder="https or http" />
<button type="submit">Go</button>
</form>
<iframe style="width: 80%; height: 80%;" id="iframe"></iframe>
var url = '<?php echo $url; ?>';
var frame = document.getElementById('iframe');
iframe.src = url;
HTML:
<?php
if(isset($_GET['www'])) {
$url = $_GET['www'];
} else {
$url = 'https://www.google.com/';
}
?>
<strong>Enter URL:</strong>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="text" name="www" size="50" placeholder="https or http" />
<button type="submit">Go</button>
</form>
<iframe style="width: 80%; height: 80%;" id="iframe"></iframe>
var url = '<?php echo $url; ?>';
var frame = document.getElementById('iframe');
iframe.src = url;
输入URL:
你的问题不清楚。顺便说一下,您似乎正在尝试在iframe
中导航,这应该使用JavaScript完成