Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检索客户端页面的iframe值_Php_Javascript_Html_Iframe_Client Side - Fatal编程技术网

Php 检索客户端页面的iframe值

Php 检索客户端页面的iframe值,php,javascript,html,iframe,client-side,Php,Javascript,Html,Iframe,Client Side,如何从iframe表单id中检索值,并将其调用到客户端html (客户端html) sample.html <head> <script> function alertThis(){ alert(parent.myframe.formsubmit.a_token.value); } </script> </head> <body> <iframe

如何从iframe表单id中检索值,并将其调用到客户端html

(客户端html) sample.html

<head>
    <script>
        function alertThis(){
            alert(parent.myframe.formsubmit.a_token.value);
        }
    </script>
</head>

<body>

    <iframe name = "myframe" src="http://domain.com/sample/index.php">
    <button onClick = "alertThis();">Click Here</button>

</body>

函数alertThis(){
警报(parent.myframe.formsubmit.a_token.value);
}
点击这里
(服务器端php) index.php

<form name = "formsubmit">
      <input id = "a_token"  value="<?php echo $_SESSION['user'] ?>"/>
</form>

试试这个密码

<iframe name="myframe" id="myframe" src="http://domain.com/sample/index.php">

function alertThis(){
   var content = window.frames['myframe'].document.forms['formsubmit'].elements['a_token'].value;
   alert(content);
}

var doc=window.frames['myframe'].document.getElementById('a_标记')。值; 警报(doc)


试试这个。

但仍然不起作用,我想我必须找到另一种方法,使用javascript加载我的php,以获取存储在php中的值。如果你碰巧知道一些想法,你能借一些吗?XD@RobinCarloCatacutan我刚刚用FF检查了第一个解决方案,因为我使用了FF。现在我刚刚添加了使用jQuery的。
$('#myframe').contents().find('a_token').val()