单击链接后在同一页面上打开一个窗口

时间:2015-06-05 05:39:13

标签: javascript html css

假设我点击一个链接。如何在同一页面上打开一个窗口。我不想要新的标签或窗口......只需点击链接就可以在那里打开一些东西 我不想在新标签页中打开时使用target_bank。我的窗口应该是链接上方显示的内容。更具体的是,如果我去www.talkingtextbook.in并假设我点击任何链接,窗口出现在同一页面上。请帮帮我怎样才能做到这一点

这个方法有帮助??

window.open("www.youraddress.com","_self")

4 个答案:

答案 0 :(得分:1)

尝试

  

的onClick =" window.location的=' www.youraddress.com'"

它会在同一个窗口打开新网址

答案 1 :(得分:0)

是 我们可以像使用锚一样。 例如: 假设这是菜单链接

<a href="#sample1">Menu</a>

和内容div是:

<div id="sample1">Content</div>

就像我们可以添加其他项目一样 对于弹出窗口需要添加类似“a”标签的onclick,我们可以使用jQuery显示/隐藏

答案 2 :(得分:0)

使用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;
}

答案 3 :(得分:0)

  

请试一试。

window.open("", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
  

window.open中的第一个参数,我留空了。你可以指定URl   显示该页面。或者你需要什么。(你形成等)。

     

top - &gt;它指定要在其上显示新窗口的位置   同一页。