HTML iFrame hide/show

北城余情 提交于 2019-12-11 17:28:49

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12712814/html-iframe-hide-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!