js onclick跳转页面

    // url 便是需要跳转的地址,列:'192.168.0.110:8080'
    function onclick(url){
        let aEle = document.createElement("a");
        aEle.setAttribute("href", url);
        aEle.setAttribute("target", "_Blank");
        aEle.setAttribute("id", "previewJumpEle");
        // 防止重复添加
        if (!document.getElementById("previewJumpEle")) {
        document.body.appendChild(aEle);
        }
        // 模拟点击
        aEle.click();
        (aEle.remove && aEle.remove()) || (aEle.removeNode && aEle.removeNode(true));
    }

猜你喜欢

转载自blog.csdn.net/weixin_70862058/article/details/132067625