window open 快顯視窗 和 同一視窗下開啟新標籤頁

來源:互聯網
上載者:User

標籤:status   pen   col   getattr   div   頁面   lan   elinks   color   

<!DOCTYPE html><html lang="en" dir="ltr">    <head>        <meta charset="utf-8">        <title></title>    </head>    <body>        <a href="https://www.baidu.com/"  class ="popup">            百度一下</a>            <!-- onclick = ‘return false‘ ,點擊後不跳轉了 -->        <script type="text/javascript">            // 輔助函數            var addLoadEvent = function(func) {                var oldonload = window.onload;                //將已有的儲存,如果已有                if (typeof window.onload !== ‘function‘ ) {                    window.onload = func;                } else {                    window.onload = function(){                        oldonload();                        func();                    }                }            }            addLoadEvent(prepareLinks);            // 主函數            function prepareLinks() {                // 此處表達成var prepareLinks = function(){ , 則函數無效,到這就不運行了???                if(!document.getElementsByTagName) return false;                var links =document.getElementsByTagName(‘a‘);                for (var i = 0; i < links.length; i++) {                    if (links[i].getAttribute(‘class‘) == ‘popup‘) {                        //包含了 對 ‘popup‘ 是否存在的判斷                        links[i].onclick = function(){                            return popUp(this.getAttribute("href")) ? false : true;                            //return !popUp(this.getAttribute("href"));                        }                    }                }            }            // 點選連結 不跳轉頁面 ,快顯視窗            var popUp = function(winURL) {                window.open(winURL,"popup","resizable,scrollbars,status");                return true;            }            // 若 popUp 改成如下,則點選連結 在同一視窗下開啟 新標籤頁面            // var popUp = function(winURL) {            //     window.open(winURL, ‘_blank‘);            //             return true;            // }        </script>    </body></html>

 

window open 快顯視窗 和 同一視窗下開啟新標籤頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.