简体   繁体   English

在后台打开弹出窗口?

[英]Opening a popup window in the background?

Is there a way in jquery to my browser is not moved by clicking on a link to the new window, so I just stayed in the open window. 有没有一种方法可以通过单击指向新窗口的链接来移动到我的浏览器的jQuery,所以我只是停留在打开的窗口中。

Just as it is on the page: 就像页面上一样:

http://www.netvouchercodes.co.uk/expiring-voucher-codes http://www.netvouchercodes.co.uk/expiring-voucher-codes

when you click the Get code & visit, we are on the home page and a window opens in the background. 当您单击获取代码并访问时,我们在主页上,并且在后台打开一个窗口。

How do you modify my code to make it work: 您如何修改我的代码以使其起作用:

Html: HTML:

<a href="http://www.yoursite.com/otherLink"  class="yourLink">Click here</a>

Jquery: jQuery:

$('a.yourLink').click(function(event) {
    $(this).next('.hiddenDiv').show();
    window.open(this.href, '_blank');
    $(this).remove();

    return false;
});

CSS 的CSS

.hiddenDiv{
    display:none;
}

The popup opens in a foreground window both on Opera and FF. 弹出窗口在Opera和FF的前景窗口中打开。 Are you sure you simply haven't changed some browser settings so that your browser opens popups in a background tab? 您确定只是没有更改某些浏览器设置,以便您的浏览器在后台选项卡中打开弹出窗口吗? Also, holding down CTRL while clicking on the link will open it in background. 同样,在单击链接时按住CTRL键将在后台将其打开。

The href does the magic automatically to you, so you don't need to change the location via Javascript. href自动为您完成操作,因此您不需要通过Javascript更改位置。 Also, if you handle the hyperlink's click and return it as false, it means for the browser that you didn't clicked at all, so just remove the window.open and the return false , then it should solve your problem: 另外,如果您处理超链接的单击并将其返回为false,则对于您根本没有单击的浏览器,因此只需删除window.open返回false ,则它应该可以解决您的问题:

Html: HTML:

<a href="http://www.yoursite.com/otherLink" class="yourLink">Click here</a>

JQuery: jQuery的:

$('a.yourLink').click(function(event) {
    $(this).next('.hiddenDiv').show();
    $(this).remove();
});

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

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