我有以下代码:正在显示 Iframe,但我喜欢隐藏它,直到提交表单。使用 Div 代替 iframe 是否更好?我喜欢在提交表单时删除已经存在的 div。
<script type="text/javascript">
function showIFrame() {
var iframe = document.getElementById("myiframe");
iframe.style.display="block";
}
</script>
在我的 css 文件中
#myiframe {
display:none; }
<form name="search" id="search" method="get" action="http://tmccaffery.outsideagents.com/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>
最佳答案
您在 HTML 中使用 id="myframe"
,在 CSS 中使用 #myiframe
。
将 id="myframe"
更改为 id="myiframe"
或将 #myiframe
更改为 #myframe
.
关于javascript - iframe点击后才显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15480936/