我是javascript的新手。现在我在主页中有一个链接重定向到其他html页面,但我想在我的主页中显示它作为响应和一些角落的样式折叠。在javascript中有任何方法可以做到这一点。< / p>
谢谢
答案 0 :(得分:2)
您只需使用<iframe>
即可在模态内容中显示其他网页内容。
$(window).load(function(){
$('#exampleModal').modal('show');
});
&#13;
iframe {
display:block;
width:100%;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<iframe src="www.google.com">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
&#13;
答案 1 :(得分:0)
它被称为“模态框”,这是如何做到的:https://www.w3schools.com/howto/howto_css_modals.asp
至于样式,您可以简单地使用 CSS。例如对于链接示例中的 round corner,只需添加例如border-radius: 25px;
到 .modal-content
,以便您
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
border-radius: 25px;
}
具体来说,对于折角,也有很多例子,例如https://codepen.io/brownerd/pen/lEHwL 或 https://stackoverflow.com/a/55457088/9593181