我们开设了一个iframe
在模式对话框中。在里面iframe
我们正在加载一个document
。该文档也是 html 页面。这<a>
文档中的标签未导航至id
他们中提到的href
.
只是来自的一个样本html
文档。
下面是<a>
例子,
<a data-custom-class="link" href="#infoshare">
2. WILL YOUR INFORMATION BE SHARED WITH ANYONE?
</a>
<p id="infoshare" style="font-size:15px;">
<span style="color: rgb(0, 0, 0);">
<strong>
<span style="font-size: 19px;">
<span data-custom-class="heading_1">
2. WILL YOUR INFORMATION BE SHARED WITH ANYONE?
</span>
</span>
</strong>
</span>
</p>
单击<a>
它应该导航到<p>
.
不过,当在浏览器中浏览 url 时,它可以完美运行。
但在对话模型中不起作用。
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("infoshare");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
<a data-custom-class="link" id="infoshare">
2. WILL YOUR INFORMATION BE SHARED WITH ANYONE?
</a>
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p>Some text in the Modal..</p>
</div>
</div>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)