HTML iFrame隐藏/显示 [英] HTML iFrame hide/show

查看:708
本文介绍了HTML iFrame隐藏/显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一个iframe的上传选项。所以这里是我的HTML:

 < 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标记中。

然后你可以在PHP响应中添加一个javascript代码从父页面调用一个函数。就像这样:

  // .. 
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆