HTML 点击超链接弹出 iframe 窗口示例
以下是一个用 HTML 编写的点击超链接弹出 iframe 窗口的示例代码:
<!DOCTYPE html>
<html>
<head>
<title>点击超链接弹出 iframe 窗口</title>
<style>
/* 样式可以根据自己的需要进行修改 */
#iframeBox {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 60%;
height: 60%;
background-color: #ffffff;
border: 1px solid #000000;
z-index: 9999;
overflow: auto;
}
</style>
</head>
<body>
<!-- 点击该超链接将弹出 iframe 窗口 -->
<a href='#' onclick='document.getElementById('iframeBox').style.display='block';'>点击打开 iframe 窗口</a>
<!-- iframe 窗口 -->
<div id='iframeBox'>
<iframe src='https://www.baidu.com'></iframe>
<!-- 点击关闭按钮将关闭 iframe 窗口 -->
<button onclick='document.getElementById('iframeBox').style.display='none';'>关闭</button>
</div>
</body>
</html>
在这个示例中,我们创建了一个超链接,当点击该超链接时,会触发一个 JavaScript 函数,以显示一个包含 iframe 的弹窗窗口。当 iframe 窗口显示时,网页上的其他元素都会被遮挡,并且在关闭按钮被点击时,iframe 窗口会被隐藏。
原文地址: https://www.cveoy.top/t/topic/mZzT 著作权归作者所有。请勿转载和采集!