iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
一些JQUERY插件源码里都看了这一句,不知道是做什么用的 有一段注释: // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
欢迎选择我的课程,让我们一起见证您的进步~~
1、正则判断当前 url 是否以 https 开头
/^https/i.test(window.location.href || '')
1、1 利用短路防止 test 的参数为 undefined 或 null,即当 window.location.href 为 undefined 或者 null 时,test 可获得 || 后的 '' 作为参数
window.location.href || ''
2、三元运算(boolean ? reg1 : reg2),当前 url 以 https 开头则 iframeSrc 值为 'javascript:false',否则为 'about:blank'
iframeSrc:/^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
1、正则判断当前 url 是否以 https 开头
1、1 利用短路防止 test 的参数为 undefined 或 null,即当 window.location.href 为 undefined 或者 null 时,test 可获得 || 后的 '' 作为参数
2、三元运算(boolean ? reg1 : reg2),当前 url 以 https 开头则 iframeSrc 值为 'javascript:false',否则为 'about:blank'