第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

建立一個鏈接打開一個新窗口(而不是標簽)

建立一個鏈接打開一個新窗口(而不是標簽)

梵蒂岡之花 2019-08-12 16:06:33
建立一個鏈接打開一個新窗口(而不是標簽)有沒有辦法讓鏈接打開一個新的瀏覽器窗口(而不是選項卡)而不使用JavaScript?
查看完整描述

3 回答

?
慕的地8271018

TA貢獻1796條經(jīng)驗 獲得超4個贊

這將打開一個新窗口,而不是tab(使用JavaScript,但非常簡潔):

<a href="print.html"  
    onclick="window.open('print.html', 
                         'newwindow', 
                         'width=300,height=250'); 
              return false;"
 >Print</a>


查看完整回答
反對 回復 2019-08-12
?
12345678_0001

TA貢獻1802條經(jīng)驗 獲得超5個贊

我知道它有點舊Q但是如果你通過搜索解決方案來到這里,所以我通過jquery得到了一個很好的

  jQuery('a[target^="_new"]').click(function() {
    var width = window.innerWidth * 0.66 ;
    // define the height in
    var height = width * window.innerHeight / window.innerWidth ;
    // Ratio the hight to the width as the user screen ratio
    window.open(this.href , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));});

它將<a target="_new">在一個新窗口中打開所有內容

編輯:

1,我在原始代碼中做了一些小改動現(xiàn)在它完全按照用戶屏幕比例打開新窗口(對于橫向桌面)

但是,我建議您使用以下代碼,如果您在移動設備中打開新標簽中的鏈接:

jQuery('a[target^="_new"]').click(function() {
    return openWindow(this.href);}function openWindow(url) {

    if (window.innerWidth <= 640) {
        // if width is smaller then 640px, create a temporary a elm that will open the link in new tab
        var a = document.createElement('a');
        a.setAttribute("href", url);
        a.setAttribute("target", "_blank");

        var dispatch = document.createEvent("HTMLEvents");
        dispatch.initEvent("click", true, true);

        a.dispatchEvent(dispatch);
    }
    else {
        var width = window.innerWidth * 0.66 ;
        // define the height in
        var height = width * window.innerHeight / window.innerWidth ;
        // Ratio the hight to the width as the user screen ratio
        window.open(url , 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ((window.innerHeight - height) / 2) + ', left=' + ((window.innerWidth - width) / 2));
    }
    return false;}


查看完整回答
反對 回復 2019-08-12
  • 3 回答
  • 0 關注
  • 606 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號