//点击外链询问离开
var cklink = 1;
function extLink(act){
if( act == false ){
cklink = 0;
}else{
cklink = 1;
}
}
$(document).on('click','a',function(){
if( cklink == 0 ) return;
if ( $(this).hasClass('ncolink') ) return;
var o = $(this);
var href = o.attr('href');
var host = getHost(href);
var ckhost = href.indexOf('shunde.gov.cn/chencun');
if( host != 'null' && ckhost <= 0 && typeof(href)!='undefined' && o.data('ask')!='1'){
o.removeAttr('href');
var jx = true;
var w = '480px';
var h = '180px';
if(window.screen.width < 768) { w = '90%'; h = '180px';}
var cf = layer.confirm('
您访问的链接即将离开“佛山市顺德区陈村镇人民政府网” 是否继续?
', {
btn:[ '继续访问', '放弃' ],
title: false,
shade: 0.7,
area: [w, h],
cancel: function(index){ o.attr('href',href); }
}, function() {
o.attr('href',href);
o.attr('target','_blank');
o.data('ask','1');
layer.close(cf);
o[0].click();
}, function() {
o.attr('href',href);
});
}
});
//截取URL域名部份
var getHost = function(url) {
var host = "null";
if (typeof url == "undefined" || null == url) url = window.location.href;
var regex = /.*\:\/\/([^\/]*).*/;
var match = url.match(regex);
if (typeof match != "undefined" && null != match) host = match[1];
return host;
};