我的表单上有这个变量
<script>
var type = 2;
</script>
在同一页面上我调用此 iFrame
<iframe src='http://www.genpowerusa.com/crm/formal_quote_new2.php' frameborder='0'></iframe>
我不确定的是,我如何将变量发送到 php 表单并在报价表单上使用该变量,该变量是静态的,我有两个页面调用相同的 iFrame。
这样的事可能吗?
最佳答案
为您的 iframe 分配一个 id:
<iframe id='foo' src='http://www.genpowerusa.com/crm/formal_quote_new2.php' frameborder='0'></iframe>
添加js行:
document.getElementByid("foo").src='http://www.genpowerusa.com/crm/formal_quote_new2.php?type='+type;
它的作用是将你的变量作为 PHP url 参数传递。你可以在 php 中使用以下代码来访问它:
$type=$_GET['type'];
关于javascript - 如何将 JS 变量发送到 php iFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21971993/