$(function() { //判断终端 var u = navigator.userAgent; var isiOS = u.match(/(iPhone|iPod|iPad);?/i); if(isiOS) { $("a").each(function() { var href = $(this).attr("href") console.log(href) if(href != undefined) { $(this).removeAttr("target") if(href.indexOf("https://") != -1) { $(this).attr("target", "_blank") } else if(href.indexOf("") != -1) { $(this).attr("target", "_blank") } else { } } }) $('a:not([target])').click(function() { console.log($(this).attr('href')) self.location.href = $(this).attr('href'); return false; }); } })