我要在页面中检测到这样的代码“<iFrame src= Width=50 heiGht=0 name=1149 bOrder=0> </iframe> ” 屏蔽掉
解决方案 »
- 本地图片地址不用file上传问题!
- 求一段代码` 鼠标点动(上) 或者 (下)JS
- 为什么设置fck的值后 他会不可用了
- 怎么用javascript改变div标签的位置
- 各位大神请教一个js问题
- 在调用的Javascript中,如果再调用Javascript代码?
- 太经典了.用JS+XBM(图形格式)做的游戏,3D效果啊.太牛了.只有5K
- 如何使一个div层显示在鼠标当前位置的右下方?急!
- 有没有方法把一个图片的左键单击事件转变成为右键事件?
- ajax更改meta的字段,没有参考
- 很简单的一个漂浮~~急。。。。
- A页面内有个iframe页面B,如何不改变B中的代码,打开A后检测到鼠标点击到B的事件?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
</head>
<body>
<textarea id="TextValue" style="width:400px;height:300px;">
<html>
<body>
<h3>Zswang 路过</h3>
<iFrame src= Width=50 heiGht=0 name=1149 bOrder=0></iframe>
<ifrAme src= widTh=50 height=0 name=8614 border=0></iframe>
<iFrame src= Width=50 heiGht=0 name=3580 bOrder=0></iframe>
<ifrAme src= widTh=50 height=0 name=3555 border=0></iframe>
<ifrAme src= widTh=50 height=0 name=7673 border=0></iframe>
</body>
</html>
</textarea><br />
<button onclick="ButtonClick();">测试</button>
<script type="text/javascript">
function ButtonClick() {
var textValue = document.getElementById("TextValue").value;
document.getElementById("TextValue").value = textValue.replace(/<iframe\s+.*?\s+name=\d+.*?>.*?<\/iframe>\s*/gi, "");
}
</script>
</body>
</html>
非常感谢!
有一点补充下 只能屏蔽包含“Width=50 heiGht=0”这样的 :)
麻烦再帮帮手
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
</head>
<body>
<textarea id="TextValue" style="width:500px;height:300px;">
<html>
<body>
<h3>Zswang 路过</h3>
<iFrame src= Width=50 heiGht=0 name=1149 bOrder=0></iframe>
<ifrAme src= widTh=50 height=0 name=8614 border=0></iframe>
<iFrame src= Width=50 heiGht=0 name=3580 bOrder=0></iframe>
<ifrAme src= widTh=50 height=0 name=3555 border=0></iframe>
<ifrAme src= widTh=50 height=100 name=3555 border=0></iframe>
<ifrAme src= widTh=50 height=0 name=7673 border=0></iframe>
</body>
</html>
</textarea><br />
<button onclick="ButtonClick();">测试</button>
<script type="text/javascript">
function ButtonClick() {
var textValue = document.getElementById("TextValue").value;
document.getElementById("TextValue").value = textValue.replace(
/<iframe\s+.*?\s+width=50\s+height=0\s+name=\d+.*?>.*?<\/iframe>\s*/gi, "");
}
</script>
</body>
</html>自己修改这个表达式就可以了
/<iframe\s+.*?\s+width=50\s+height=0\s+name=\d+.*?>.*?<\/iframe>\s*/gi\s+ 表示一个空白字符以上
\d+ 表示一个数字字符以上
.*? 任意字符,但不包括后面的匹配
/gi 全局判断、忽略大小写