<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000"><!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试1" TAG="BODY" PREVIEW="测试1" id="__enpspecial_b15e0bc93d384da6ac8b866e2ec93213" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" -->
<!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试2" TAG="BODY" PREVIEW="测试2" id="__enpspecial_77803a050a384e35af37a2dd63772da1" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" --></body>
</html>
<SCRIPT LANGUAGE="JavaScript">
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
var html = document.documentElement.innerHTML;
var a = html.match(/(<!--)([^\1]+?)-->/g);
alert(a[0].getAttribute("comstring"));
alert(a[2].getAttribute("id"));
</SCRIPT>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000"><!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试1" TAG="BODY" PREVIEW="测试1" id="__enpspecial_b15e0bc93d384da6ac8b866e2ec93213" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" -->
<!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试2" TAG="BODY" PREVIEW="测试2" id="__enpspecial_77803a050a384e35af37a2dd63772da1" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" --></body>
</html>
<SCRIPT LANGUAGE="JavaScript">
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
var html = document.documentElement.innerHTML;
var a = html.match(/(<!--)([^\1]+?)-->/g);
alert(a[0].getAttribute("comstring"));
alert(a[2].getAttribute("id"));
</SCRIPT>
解决方案 »
- 关于jquery的each方法
- 对声明数组[] ,new Array()不理解
- 高手帮我看看这个简单的验证,怎么出错了?
- 大家怎么做项目进度和工作进度估算的?
- 这个innerHtml有什么问题吗?没作用啊
- 请问用javascript怎么实现对广告框架<iframe src=广告地址></iframe>点击计数呢??
- 关于文本框的Disabled和ReadOnly
- 如何加密asp呢?要求非常严格的
- 那位高手 , 解釋一下 event.cancelBubble=true 的用法 , 謝了
- jqplot 中的shapeRenderer 画任意矩形,有知道的吗?
- 提示“缺少对象”,动态生成的js函数如何调用?
- 一个搞了我一下午的计算题!
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
var html = document.documentElement.innerHTML;
var a = html.match(/(<!--)([^\1]+?)-->/g);
html = html.replace(a[0]+a[1], "\nmeizz1");
html = html.replace(a[2]+a[3], "\nmeizz2");
alert(html);
</SCRIPT>
再次非常感谢但是现在有个问题哈: 就是页面中究竟有多少个 象 <!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试2" TAG="BODY" PREVIEW="测试2" id="__enpspecial_77803a050a384e35af37a2dd63772da1" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" --> 的代码,我根本就无法知道啊??
怎样才能将所有的都替换掉???/
html = html.replace(a[2]+a[3], "\nmeizz2");
都指明了具体的“位置代号”a[0] a[2]
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
var html = document.documentElement.innerHTML;
var a = html.match(/(<!--)([^\1]+?)-->/g);
for(var i=0; i<a.length-1; i=i+2)
{
html = html.replace(a[i]+a[i+1], "\nmeizz"+i );}
alert(html);
</SCRIPT>
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
function afterOnLoad()
{
var html = document.documentElement.innerHTML;
var a = html.match(/(<!--)([^\1]+?)-->/g);
for(var i=0; i<a.length; i=i+2)
{
html = html.replace(a[i]+a[i+1], "\nmeizz"+i ); }
alert(html);
}
window.attachEvent("onload", afterOnLoad);<html>
<head>
<title>无标题文档</title>
<script language="javascript" src="mm.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000"><!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试1" TAG="BODY" PREVIEW="测试1" id="__enpspecial_b15e0bc93d384da6ac8b866e2ec93213" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" -->
<!--webbot bot="AdvTitleList" nodeid="" type="" spanmode="0" dayspan="0" attr="" comstring="测试2" TAG="BODY" PREVIEW="测试2" id="__enpspecial_77803a050a384e35af37a2dd63772da1" startspan --><!--webbot bot="AdvTitleList" endspan i-checksum="0" --></body>
</html>
String.prototype.getAttribute = function(name)
{
var reg = new RegExp("\\b"+ name +"\\s*=\\s*(\\\'|\\\")([^\\1]*?)\\1", "i");
if (reg.test(this)) return RegExp.$2; return "";
}
function afterOnLoad()
{
var html = document.documentElement.innerHTML;
var reg = new RegExp("<\!--webbot([\\w\\W]+?)--><\!--webbot([\\w\\W]+?)-->", "gi");
var a = html.match(reg);
for(var i=0; i<a.length; i++)
{
html = html.replace(a[i], "\nmeizz"+i ); }
alert(html);
}
window.attachEvent("onload", afterOnLoad);
搞定,太谢谢 meizz(梅花雪) 了!说到做到 + 80 共 100 分,请查收!