외부링크면 무조건 새창으로 열리게 하는 그런 기능의 자료가 있나요?
이거 은근히 신경쓰이죠...
운영자 입장에서는 외부사이트로 전환되면 다시 돌아오기 불편한 현재창에서 열리는게 별고 달갑지 않지요.
이거 혹시 자료가 ... 있을까요?
외부링크면 무조건 새창으로 열리게 하는 그런 기능의 자료가 있나요?
이거 은근히 신경쓰이죠...
운영자 입장에서는 외부사이트로 전환되면 다시 돌아오기 불편한 현재창에서 열리는게 별고 달갑지 않지요.
이거 혹시 자료가 ... 있을까요?
jQuery(function() {
jQuery('.xe_content[class^=document_] a, .xe_content[class^=comment_] a').each(function() {
if(this.hostname !== window.location.hostname) {
$(this).attr('target', '_blank');
}
});
});
if(this.hostname !== window.location.hostname) {
이 부분을 수정해야 할 것입니다.
각각 값을 확인해봐야 할듯 하네요.
this.hostname 대신
jQuery(this).attr('href')를 쓰면 어떨까 합니다.
그리고 !==가 아닌 문자열 찾기인 indexOf로 비교하면 어떨까 하구요.
jQuery('.xe_content[class^=document_] a, .xe_content[class^=comment_] a').each(function() {
var a = jQuery(this).attr('href');
var b = /((https?:)?\/{2}(?!xetown)[\da-z\.-]+\.[a-z\.]{2,}[\w\/?&;=#%~\.-]*[\/]?)/g;
if(b.test(a)) {
$(this).attr('target', '_blank');
}
});
일케 하면 될런지.. 중간에 xetown 만 바궈서 한번 해보세요
----------- 그냥 처음 거 쓸게요... 도움 감사했습다. -------------
jQuery(function(){ jQuery('.xe_content[class^=document_] a').attr('target', '_blank'); });
jQuery(function(){ jQuery('.xe_content[class^=comment_] a').attr('target', '_blank'); });이거로 해도 본문에 저희 사이트 링크 적을때 _self 로 하면 새창으로 안뜨는 듯 합니다.
새창으로 뜨지만.. ㅋㅋ
많은 답변 감사했습니다.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function() {
$("a[href^='http://']").each(
function(){
if(this.href.indexOf(location.hostname) == 1) {
$(this).attr('target', '_self');
}
}
);
$("a[href^='https://']").each(
function(){
if(this.href.indexOf(location.hostname) == 1) {
$(this).attr('target', '_self');
}
}
);
});
</script>
될려나요.
이 스크립트를 board.js 에 그대로 넣으면 되나요?
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
포함해서 스킨에 넣어야 하는건가요??
검색을 하다보니 이런 댓글이 보이는데요..
board.default.js 파일에...
jQuery(function(){ jQuery('.xe_content[class^=document_] a').attr('target', '_blank'); });
jQuery(function(){ jQuery('.xe_content[class^=comment_] a').attr('target', '_blank'); });
이게 잘 되는거면 여기서 자신의 사이트가 아니라면 이라는 조건을 걸어줄 수 있을까요?
윽.. 스케치북5 js 에는 저런게 없네요 ㅡㅡ;