问题
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