【发布时间】:2014-05-11 14:26:45
【问题描述】:
我有一个基本的 html 表单页面,用户在其中输入一个单词,然后提交到一个带有 iframe 的 php 页面,然后在 wikipedia 中搜索该术语,如下所示:
<?php
$userEntered = $_POST["userEntered"];
echo
'<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Full Page IFrame</title>
<style type="text/css">
html {overflow: auto;}
html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
</style>
</head>
<body>
<iframe id="tree" name="tree" src="http://en.wikipedia.org/wiki/' . $userEntered . '" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"></iframe>
</body>
</html>';
?>
我想知道每次用户点击维基百科页面上的链接时如何创建一个新变量。
即使您导航到 iframe 中的新维基百科页面,$userEntered 变量似乎也保持不变。
【问题讨论】:
-
在表单中输入一个文本字段,然后提交并设置 target= iframe
-
iframe 内容是完全独立的网页。在其中单击的链接不会影响包含页面。除非他们有
target="_top"或一些 JS 代码来突破框架。