用javascript实现自定义标签
发布时间:2016-12-30 来源:查字典编辑
摘要://byzdzhuovard=document;varmk=newArray('','','','','','','','','','','...
//byzdzhuo
<html>
<head>
<scripttype="text/javascript">
vard=document;
varmk=newArray(
'<red>','<spanstyle="color:red;">',
'</red>','</span>',
'<big>','<spanstyle="font-size:22pt;">',
'</big>','</span>',
'<zhuo>','<spanstyle="font-style:oblique;">',
'</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>