admin管理员组文章数量:1405393
I have the following code: Iframe is being shown but I like to hide it until form is submitted. is it better maybe to use Div instead of iframe? I like to get get rid of div thats already there when form is submitted.
<script type="text/javascript">
function showIFrame() {
var iframe = document.getElementById("myiframe");
iframe.style.display="block";
}
</script>
in my css file
#myiframe {
display:none; }
<form name="search" id="search" method="get" action=".rvlx" target="carsearch">
<iframe id="myframe" name="carsearch" width="535" height="625" scrolling="no" frameborder="0"></iframe>
<button type="submit" id="SearchCarButton" class="submitBtn" onclick="showIFrame()"/> <span>Search</span></button>
I have the following code: Iframe is being shown but I like to hide it until form is submitted. is it better maybe to use Div instead of iframe? I like to get get rid of div thats already there when form is submitted.
<script type="text/javascript">
function showIFrame() {
var iframe = document.getElementById("myiframe");
iframe.style.display="block";
}
</script>
in my css file
#myiframe {
display:none; }
<form name="search" id="search" method="get" action="http://tmccaffery.outsideagents./travel/car/search.rvlx" target="carsearch">
<iframe id="myframe" name="carsearch" width="535" height="625" scrolling="no" frameborder="0"></iframe>
<button type="submit" id="SearchCarButton" class="submitBtn" onclick="showIFrame()"/> <span>Search</span></button>
Share
Improve this question
asked Mar 18, 2013 at 15:44
Thomas MccafferyThomas Mccaffery
3952 gold badges3 silver badges10 bronze badges
5 Answers
Reset to default 1You're using id="myframe"
in the HTML and #myiframe
in the CSS.
Either change id="myframe"
to id="myiframe"
or change #myiframe
to #myframe
.
iframe.style.visibility="hidden";
and to show it:
iframe.style.visibility="visible";
Edit: And you can use the onsubmit="JavaScriptCode" event to trigger the change.
Reference: http://www.w3schools./jsref/event_form_onsubmit.asp
Change your script to this :)
<script type="text/javascript">
function showIFrame() {
var iframe = document.getElementById("myiframe");
iframe.style.visibility="visible";
}
</script>
You're using the wrong id - in your css you're using "#myiframe" instead of "#myframe" - no "i".
Here's the correct code:
#myframe { display:none; }
jQuery have load event that is executed when iframe is loaded:
$('#myframe').load(function() {
$(this).show();
});
本文标签: javascriptiframe show only after clickStack Overflow
版权声明:本文标题:javascript - iframe show only after click? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744872620a2629720.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论