用javascript实现自定义标签
发布时间:2016-12-30 来源:查字典编辑
摘要://byzdzhuovard=document;varmk=newArray('','','','','','','','','','','...
//byzdzhuo
<html>
<head>
<scripttype="text/javascript">
vard=document;
varmk=newArray(
'<red>','<span>',
'</red>','</span>',
'<big>','<span>',
'</big>','</span>',
'<zhuo>','<span>',
'</zhuo>','</span>',
'<next>','<br><br>'
);
functionmark(){
vart=newString(d.body.innerHTML);
for(i=0;i<mk.length;i+=2)t=t.replace(newRegExp(mk[i],'gi'),mk[i+1]);
d.body.innerHTML=t;
}
</script>
</head>
<bodyonload="mark();">
<red>zdzhuo</red>
<next>
<big>zdzhuo</big>
<next>
<zhuo>zdzhuo</zhuo>
</html>