【发布时间】:2021-04-09 02:42:26
【问题描述】:
加载 HTML 页面后,我的 iframe 网页立即可见。我不希望这种情况发生。它应该只在单击按钮时显示。为什么会这样?
<!DOCTYPE html PUBLIC>
<html>
<body>
<form> <button type="button" id="Open_Frame" onclick="show_iframe">Files</button> </form>
<iframe id="iframe"
src="https://picsum.photos/200/300"
style="
position: fixed;
top: 0;
bottom: 0;
left: 0;
margin: auto;
right: 100px;
height: 80%;
width: 80%;
overflow: hidden;
z-index: 10;
">
</iframe>
</body>
</html>
<script>
function show_iframe() {
//Display iframe on click
}
</script>
【问题讨论】:
-
这能回答你的问题吗? How to load a iframe only on button click
标签: javascript html iframe