1

ボタンをクリックして 2 つの異なるウィンドウを開こうとしていますが、ボタンをクリックすると同じウィンドウが 2 回開きます。これは私の機能です:

function flush(form) {
    var custid = form.custid.value;
    var url1 = "https://www.blabla.com?type=customer&id="+custid;
    flushWindow1 = window.open(url1);
    var url2 = "https://web.blabla.com?type=customer&id="+custid;
    flushWindow2 = window.open(url2);
}  

誰も私がこれを行う方法を知っていますか?

4

3 に答える 3

0

ウィンドウの名前である window.open() メソッドに 2 番目の引数を指定してみてください。名前が異なる場合、同じ URL が別のウィンドウで開きます。例えば

function flush(form) {
    var custid = form.custid.value;
    var url1 = "https://www.blabla.com?type=customer&id="+custid;
    flushWindow1 = window.open(url1,"flushWindow1");
    var url2 = "https://web.blabla.com?type=customer&id="+custid;
    flushWindow2 = window.open(url2,"flushWindow2");   
}

デモ

于 2012-10-08T10:27:34.007 に答える
0

パラメータを追加して新しいウィンドウ/タブで開いてみて、2つの新しいウィンドウを開いた後にフォーカスしたいウィンドウの後ろの'_blank'
場所で目的のウィンドウにフォーカスしますwindow.focus();

function flush(form) {
    var custid = form.custid.value;
    var url1 = "https://www.blabla.com?type=customer&id="+custid;
    flushWindow1 = window.open(url1, '_blank');
    var url2 = "https://web.blabla.com?type=customer&id="+custid;
    flushWindow2 = window.open(url2, '_blank');
    window.focus(); // focus on url2
}  
于 2012-10-08T10:42:22.180 に答える
0

From : JSfiddle ワンクリックで 2 つのウィンドウ

$('document').ready(function(){
    $('input').click(function(){
        window.open("https://www.google.com.pk/search?q=123&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a")
        window.open("https://www.google.com.pk/search?q=abc&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a")
    });
});  
于 2012-10-08T10:38:19.717 に答える