使用iframe时在上传表单上回显PHP中的jQuery脚本
我的文件上传有以下HTML代码使用iframe时在上传表单上回显PHP中的jQuery脚本,php,javascript,jquery,iframe,Php,Javascript,Jquery,Iframe,我的文件上传有以下HTML代码 <div id="status"></div> <iframe name="upifrm" src="" style="display:none;"></iframe> <form name="myForm" id="myForm" action="upload.php" method="post" enctype="multipart/form-data" target="upifrm"> <
<div id="status"></div>
<iframe name="upifrm" src="" style="display:none;"></iframe>
<form name="myForm" id="myForm" action="upload.php" method="post" enctype="multipart/form-data" target="upifrm">
<label for="fileinput" id="brsbtn" class="labtrigg">label</label>
<input type="file" id="fileinput" name="file" />
</form>
<div id="atchs"></div>
标签
在upload.php文件的末尾
// . . . . . . . . . . . . .
// $message declaration . . .
echo '<script>
parent.document.getElementById("myForm").reset();
parent.document.getElementById("status").innerHTML="'.$message.'";
$("#atchs", window.parent.document).after("<span>something</span>");
</script>';
/。
//$message声明。
回声'
parent.document.getElementById(“myForm”).reset();
parent.document.getElementById(“status”).innerHTML=“”.$message.”;
$(“#atchs”,window.parent.document);
';
前两行工作得很好(它们是用纯Javascript代码编写的),但我在第三行遇到了错误
$("#atchs", window.parent.document).after("<span>something</span>");
$(“#atchs”,window.parent.document);
“预期目标”。如何解决此问题?即使包含jQuery,这里也应该有一个函数名:
$("#atchs", window.parent.document).("<span>something</span>");
^^^
$(“atchs”,window.parent.document)(“某物”);
^^^
类似于append
,prepend
,html
,text
,或者任何你想做的事情。它不能只是一个点和括号。试试这个
确保在父页面中包含了jQuery
文件
top.jQuery("#atchs").html("<span>something</span>");
top.jQuery(“atchs”).html(“某物”);
希望这有意义您调用
$(“#atchs”,window.parent.document)。(“某物”)代码>在iframe中?iframe中是否包含jquery?前两行是传统的js,为什么在第三行使用jquery方法?我在主HTML文件中包含了jquery。Iframe位于这个HTML文件中。Rikesh,我想在jQuery中重写整个代码,所以上面的代码只是一个示例。谢谢。window.parent.document
<。我测试过了非常感谢你Dianuj!