简体   繁体   English

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

[英]open a window on the same page after clicking a link

suppose i click a link. 假设我单击一个链接。 How can i open a window over same page. 如何在同一页面上打开一个窗口。 I don't want a new tab or window.... just clicking a link should open something there only I don't want to use target_bank as it opens in new tab. 我不需要新的标签页或窗口...。只需单击链接即可在其中打开某些内容,只有我不想使用target_bank,因为它在新标签页中打开。 My window should be something as it appears just above the link. 我的窗口应该是链接上方显示的内容。 To be more specific if i go to www.talkingtextbook.in and suppose i click any link a window appears over the same page. 更具体地说,如果我去www.talkingtextbook.in并假设我单击任何链接,则在同一页面上会出现一个窗口。 Please help me how can i do this 请帮我怎么做

would this method help?? 这种方法有帮助吗?

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

Try 尝试

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

It will Open new url on same windows 它将在相同的窗口上打开新的URL

Yes We can do like using anchor. 是的,我们可以喜欢使用锚。 For eg: Suppose this is menu link 例如:假设这是菜单链接

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

and content div is: 内容div是:

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

Like that we can add for another items For pop up to occur need to add like "a" tag onclick and we can use that show/hide using jQuery 这样,我们可以添加另一个项目,以便弹出发生,需要在onclick上添加“ a”标记,然后我们可以使用jQuery来显示/隐藏

Use js to open a modal or lightbox plugin and skin the modal/lightbox to be 100% in width and height via css 使用js打开模式或灯箱插件,并通过CSS将模式/灯箱的宽度和高度设置为100%

Based on the page you shared you can set up the modal like this 根据您分享的页面,您可以像这样设置模式

on your html 在你的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>
...

On your js 在你的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);

on your css 在你的CSS上

.modal {
  display: none;
  overflow: hidden;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1050;
}

Please try this. 请尝试这个。

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

The first parameter in window.open , i left empty. window.open中的第一个参数,我为空。 you can specify URl to show that page. 您可以指定URl显示该页面。 or what ever you need.( you form etc). 或您需要的东西(您形成等)。

top -> it specify the position where you want to show new window on same page. 顶部->它指定要在同一页面上显示新窗口的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM