[英]open a window on the same page after clicking a link
假设我单击一个链接。 如何在同一页面上打开一个窗口。 我不需要新的标签页或窗口...。只需单击链接即可在其中打开某些内容,只有我不想使用target_bank,因为它在新标签页中打开。 我的窗口应该是链接上方显示的内容。 更具体地说,如果我去www.talkingtextbook.in并假设我单击任何链接,则在同一页面上会出现一个窗口。 请帮我怎么做
这种方法有帮助吗?
window.open("www.youraddress.com","_self")
尝试
的onClick = “window.location的= 'www.youraddress.com'”
它将在相同的窗口上打开新的URL
是的,我们可以喜欢使用锚。 例如:假设这是菜单链接
<a href="#sample1">Menu</a>
内容div是:
<div id="sample1">Content</div>
这样,我们可以添加另一个项目,以便弹出发生,需要在onclick上添加“ a”标记,然后我们可以使用jQuery来显示/隐藏
使用js打开模式或灯箱插件,并通过CSS将模式/灯箱的宽度和高度设置为100%
根据您分享的页面,您可以像这样设置模式
在你的HTML上
...
<body>
your content <a href="#" id="open-modal-1">open modal 1</a>
<div class="modal" id="modal-1">
the modal content
</div>
</body>
...
在你的js上
var trigger = document.getElementById('open-modal-1'),
modal = document.getElementById('modal-1');
trigger.addEventListener('click', function(e){
if (modal.style.display == 'block'){
modal.style.display = 'none';
}else{
modal.style.display = 'block';
}
}, true);
在你的CSS上
.modal {
display: none;
overflow: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
}
请尝试这个。
window.open("", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
window.open中的第一个参数,我为空。 您可以指定URl显示该页面。 或您需要的东西(您形成等)。
顶部->它指定要在同一页面上显示新窗口的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.