zoukankan      html  css  js  c++  java
  • window.open被拦截

    1)直接调用window.open 或 点击的时候直接调用 window.open 是不会被拦截的

    // 不会被拦截
    $('.btn-open').click(function(){ window.open('xxxx', '_blank'); });

    2)window.open 只能放函数第一层,放在函数嵌套里会被拦截

    // 会被拦截
    $('.btn-open').click(function(){ $.get('xxxx.php', function(res){ window.open(res.url, '_blank'); }, 'json'); });

    简单来说,要想不被拦截,window.open 只能放函数第一层,不能放嵌套函数里(PS:写成一个独立的函数,但调用是在嵌套函数里调用也是不行的

    // 会被拦截
    function
    openUrl(url){ window.open(url, '_blank'); } $('.btn-open').click(function(){ $.get('xxxx.php', function(res){ openUrl(res.url); }, 'json'); });
  • 相关阅读:
    JavaScript基础知识
    font属性+ul列表+table属性+border属性
    一级段项目学习
    考点整理代码块系列
    考试点总结
    JavaScript复习
    1017
    复习HTML
    1012总结
    1011js学习总结
  • 原文地址:https://www.cnblogs.com/tujia/p/7991642.html
Copyright © 2011-2022 走看看