티스토리 뷰
출처 및 참고 : http://blog.showjean.com/137
브라우저가 크롬일 경우 F12로 개발자 도구를 열어서
Elements 탭 아래(html 태그 바로 위)에 보면 아래 스크립트가 삽입되어 있음.
==>
<script type="text/javascript">
var rule = /(?:(?=(?:http|https):)([a-zA-Z][-+.a-zA-Z\d]*):(?:((?:[-_.!~*'()a-zA-Z\d;?:@&=+$,]|%[a-fA-F\d]{2})(?:[-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]|%[a-fA-F\d]{2})*)|(?:(?:\/\/(?:(?:(?:((?:[-_.!~*'()a-zA-Z\d;:&=+$,]|%[a-fA-F\d]{2})*)@)?(?:((?:(?:(?:[a-zA-Z\d](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[(?:(?:[a-fA-F\d]{1,4}:)*(?:[a-fA-F\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?:(?:[a-fA-F\d]{1,4}:)*[a-fA-F\d]{1,4})?::(?:(?:[a-fA-F\d]{1,4}:)*(?:[a-fA-F\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))?)\]))(?::(\d*))?))?|((?:[-_.!~*'()a-zA-Z\d$,;:@&=+]|%[a-fA-F\d]{2})+))|(?!\/\/))(\/(?:[-_.!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*)*(?:\/(?:[-_.!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*)*)*)?)(?:\?((?:[-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]|%[a-fA-F\d]{2})*))?)(?:\#((?:[-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]|%[a-fA-F\d]{2})*))?)/gim;
function makeHTML(textNode) {
var source = textNode.data;
return source.replace(rule, function() {
var url = arguments[0];
var a = jQuery('<a></a>').attr({
'href' : url,
'target' : '_blank'
}).text(url);
return url.match(/^https?:\/\/$/) ? url : jQuery('<div></div>').append(
a).html();
});
};
function eachText(node, callback) {
jQuery.each(node.childNodes, function() {
if (this.nodeType != 8 && this.nodeName != 'A') {
this.nodeType != 1 ? callback(this) : eachText(this, callback);
}
});
};
function autolink(obj) {
return obj.each(function() {
var queue = [];
eachText(this, function(e) {
var html = makeHTML(e);
if (html != e.data) {
queue.push([ e, makeHTML(e) ]);
}
});
jQuery.each(queue, function(i, x) {
jQuery(x[0]).replaceWith(x[1]);
});
});
}
</script>
<script type="text/javascript">
$(document).ready(function(){
autolink($("#contents"));
});
</script>
'공부 > uncategorized' 카테고리의 다른 글
HTTP Referer (0) | 2015.05.08 |
---|---|
HTML 특수문자 리스트 (0) | 2015.03.03 |
여러가지 프로그램 설치 (0) | 2014.07.27 |
[이클립스] 단축키 설정 안 먹힐 때 (0) | 2014.06.05 |
[SITE] 구글 페이지 분석 어플리케이션 - pagespped (0) | 2014.06.05 |