zoukankan      html  css  js  c++  java
  • 解决弹出的窗口window.open会被浏览器阻止的问题(自定义open方法)

    由于在使用window.open时,在很多情况下,弹出的窗口会被浏览器阻止,但若是使用a链接target='_blank',则不会,基于这一特点,自己封装了一个open方法:

    function openwin(url) {
        
    var a = document.createElement("a");
        a.setAttribute(
    "href", url);
        a.setAttribute(
    "target""_blank");
        a.setAttribute(
    "id""openwin");
        document.body.appendChild(a);
        a.click();
    }

    调用方式如下:

    <input type="button" id="btn" value="百度" onclick="openwin('http://www.baidu.com');" />
  • 相关阅读:
    Linux零拷贝技术 直接 io
    纯Python模式
    c 越界 数组越界
    哈希 二叉树
    Cache busting
    sub esp
    lisp 代码即数据
    hexdump
    nmap
    对象 闭包
  • 原文地址:https://www.cnblogs.com/linyechengwei/p/1992434.html
Copyright © 2011-2022 走看看