새 탭에서 열기, 그리고 그것은 그러나강제 링크는 내가 jQuery로 새 창에서 열기 링크를 강제로이 스크립트를 사용하고
// add external links
function addExternalLinks() {
$("a[href*='http://']:not([href*='"+location.hostname.replace
("www.","")+"']), a.linkException").each(function() {
if($(this).find('img ').length == 0) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
}).addClass('externalLink').attr("title", $(this).attr("title")+" - (This link will open in a new window)");
}
});
}
페이지의 일부가 사용을 잘 작동 LOAD를 사용하여 외부 HTML 페이지에서로드 된 내용
function showInfo(info) {
$("#layerinfo").load("descriptions.html #" + info);
};
이로드 된 콘텐츠에 포함 된 링크를 동일한 스크립트로 새 창에서 열도록하고 싶습니다. 제대로 작동하지 않습니다. 같은
뭔가 : - 어떤 도움이 크게 감사
function showInfo(info) {
var infoContent = "descriptions.html #" + info;
$("#layerinfo").load(infoContent,function(){
$("#layerinfo").html().addExternalLinks();
});
};
.
로컬로 작동하지만 서버에 업로드하면로드 된 콘텐츠에서 외부 링크가 작동하지 않습니다. 어떤 아이디어? 나는 당신의 sugestion에 따라 함수를 적용했다 : - – naturelab
// 외부 링크 추가 function addExternalLinks ( $ ("href * = 'http : //') : not ([href * = '"+ location .hostname.replace ("www.", ""+ " ']), a.linkException") 각 (function() { if ($ (this) .find ('img ') .length == 0) { $ (this) .attr ("target", "_blank") addClass ('externalLink'). attr ("title", $ (this) .attr ("title") + "- 새 창에서 열립니다. "); } }}); } – naturelab