HTML iFrame隐藏/显示 [英] HTML iFrame hide/show
问题描述
< iframe name =messagesrc =upload.php>< / iframe> ;
< form action =upload.phpmethod =postenctype =multipart / form-datatarget =message>
< input type =filename =file>
< input type =submit>
< / form>
现在的问题是iframe在转到网站的上传部分时可见。我希望它是不可见的,直到它收到来自upload.php的响应,我希望它显示的消息像一个警告框,你可以阅读然后关闭。我该如何去做呢?我猜是有一些jQuery的参与。
要隐藏iframe(或其他HTML元素),只需添加: style =display:none;
在这个HTML标记中。
// ..
echo'< script>
parent.functionName();
< / script>';
在这个函数中添加你想在php响应后执行的JavaScript指令。
I have a upload option on my website with an iframe. So here's my html:
<iframe name="message" src="upload.php"></iframe>
<form action="upload.php" method="post" enctype="multipart/form-data" target="message">
<input type="file" name="file">
<input type="submit">
</form>
The problem now is the iframe is visible when they go to the upload portion of the site. I want it to be invisible UNTIL it receives a response from upload.php, upon which I want it to show the message like an alert box which you can read then close. How do I go about doing that? I'm guessing there is some jquery involved.
To hide the iframe (or other HTML element) just add: style="display:none;"
in that HTML tag.
Then you can add in the PHP response a javascript code to call a function from parent page. Something like this:
// ..
echo '<script>
parent.functionName();
</script>';
In that function add the JavaScript instructions you want to be executed after the php response.
这篇关于HTML iFrame隐藏/显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!