mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 19:21:40 +09:00
자동링크로 인하여 생기는 자바스크립트 무한 루프 에러 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4270 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
b80ed9eb00
commit
6e46b68c70
1 changed files with 34 additions and 1 deletions
|
|
@ -11,7 +11,40 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
var url_regx = new RegExp("(http|https|ftp|news)://([^ \\r\\n]*)","i"); function replaceHrefLink(target_obj) { var obj_list = new Array(); var obj = target_obj; while(obj) { obj_list[obj_list.length] = obj; obj = obj.nextSibling; } for(var i=0;i<obj_list.length;i++) { var obj = obj_list[i]; var pObj = obj.parentNode; if(!pObj) continue; if(obj.nodeType == 1 && obj.firstChild) { replaceHrefLink(obj.firstChild); } else if(obj.nodeType == 3 && obj.data && url_regx.test(obj.data) ) { var html = obj.nodeValue.replace(url_regx,"<a href=\"$1://$2\" onclick=\"window.open(this.href); return false;\">$1://$2</a>"); var dummy = xCreateElement('span'); xInnerHtml(dummy, html); pObj.insertBefore(dummy, obj); pObj.removeChild(obj); } } } function addUrlLink() { var objs = xGetElementsByClassName('xe_content'); if(objs.length<1) return; for(var i=0;i<objs.length;i++) { if(url_regx.test(xInnerHtml(objs[i]))) replaceHrefLink(objs[i].firstChild); } } xAddEventListener(window,'load', addUrlLink);
|
||||
var url_regx = new RegExp("(http|https|ftp|news)://([^ \\r\\n]*)","i");
|
||||
function replaceHrefLink(target_obj) {
|
||||
var obj_list = new Array();
|
||||
var obj = target_obj;
|
||||
while(obj) {
|
||||
obj_list[obj_list.length] = obj;
|
||||
obj = obj.nextSibling;
|
||||
}
|
||||
for(var i=0;i<obj_list.length;i++) {
|
||||
var obj = obj_list[i];
|
||||
var pObj = obj.parentNode;
|
||||
if(!pObj) continue;
|
||||
var pN = pObj.nodeName.toLowerCase();
|
||||
if(pN == 'a' || pN == 'pre' || pN == 'xml' || pN == 'textarea' || pN == 'input') continue;
|
||||
|
||||
if(obj.nodeType == 3 && obj.data && url_regx.test(obj.data) ) {
|
||||
var html = obj.nodeValue.replace(url_regx,"<a href=\"$1://$2\" onclick=\"window.open(this.href); return false;\">$1://$2</a>");
|
||||
var dummy = xCreateElement('span');
|
||||
xInnerHtml(dummy, html);
|
||||
pObj.insertBefore(dummy, obj);
|
||||
pObj.removeChild(obj);
|
||||
} else if(obj.nodeType == 1 && obj.firstChild) {
|
||||
replaceHrefLink(obj.firstChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
function addUrlLink() {
|
||||
var objs = xGetElementsByClassName('xe_content');
|
||||
if(objs.length<1) return;
|
||||
for(var i=0;i<objs.length;i++) {
|
||||
if(url_regx.test(xInnerHtml(objs[i]))) replaceHrefLink(objs[i].firstChild);
|
||||
}
|
||||
}
|
||||
xAddEventListener(window,'load', addUrlLink);
|
||||
// ]]>
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue