强制不同的链接每次打开一个新的弹出式窗口 [英] Force different links to open in a new Pop-up window every time

查看:96
本文介绍了强制不同的链接每次打开一个新的弹出式窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,并有四个链接到不同的网页上一个新的窗口。

I have an HTML page and have Four Links to go to Different pages on a new window.

例如:

链接1,链路2,链接3 LINK4

Link1, Link2, Link3 Link4

和我想的链接1弹出一个新窗口1,链路2新窗口2,依此类推...

And I want Link 1 to pop-up in a new Window 1, Link2 to new Window 2 and so on...

因此​​,该窗口1和链接1的内容将保持被点击时,链路2

So that Window 1 and its content from Link1 will stay when Link2 is clicked.

目前,问题是这四个环节在新窗口中打开1涵盖了从Link1出现第一电流的内容。我要的是每次点击一个链接时有四个独特的窗口。

Currently, the problem is that the four links opens up in a new Window 1 covering up the first current content from Link1. What I want is to have four unique window every time a Link is clicked.

我不知道是否有一定的JavaScript函数来做到这一点,但我现在所拥有的这四个环节上只是TARGET =_空白一个锚标记。这发生在IE和Chrome,我也想在FF和任何其他浏览器。

I don't know if there's a certain Javascript function to do this but what I have right now on those four link is just target="_blank" on an anchor tag. This happens in IE and Chrome and I would think also in FF and any other browsers.

在此先感谢您的帮助。

推荐答案

目标=_空白将打开一个新窗口中的每个环节(它并不重要,如果该链接已经打开);

target="_blank" will open each link in a new window (it doesn't matter if the link is already opened);

如果您想要对焦打开的窗口中,你可以使用模态窗口(即没有选项卡)如下:

If you want to focus the opened window, you can use modal windows (i.e. not tabs) as follows:

HTML

<a href="http://google.com">link 1</a><br/>
<a href="http://yahoo.com">link 2</a><br/>
<a href="http://bing.com">link 3</a><br/>
<a href="http://mamma.com">link 4</a>

JS:

$(document).ready(function() {
    $('a').click(function(e) {
        var id = $(this).data("windowid");
        if(id == null || id.closed) {
            id =  window.open($(this).attr("href"), '_blank', 'modal=yes');
        }
        id.focus();
        $(this).data("windowid", id);
        e.preventDefault();
        return false;
    });
});

http://jsfiddle.net/JeQyE/2/

这篇关于强制不同的链接每次打开一个新的弹出式窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆