<style>
a {poorfish:expression(this.onclick=function kill(){return
false})}
</style>
如果我的回答没能帮助您,请继续追问。
您也可以向我们团队发出请求,会有更专业的人来为您解答。
你指的是禁用默认事件看
<a href="baidu.com">百度</a>1.jQuery 阻止默认事件
$("a").click(function( event ) {
event.preventDefault() // 阻止默认事件
event.stopPropagation() // 阻止冒泡
})
2.javascript
var elem = document.getElementByTagName("a")
elem.addEventListener("click",function(event){
event.preventDefault() // 阻止默认事件
event.stopPropagation() // 阻止冒泡
},false)
说明:
preventDefault() // 阻止默认事件
stopPropagation() // 阻止冒泡
return false // 既阻止默认事件 也阻止冒泡
/// <summary>/// 去除所有HTML标记
/// </summary>
public static string DeleteHtmlTag(string html)
{
html = Regex.Replace(html, @"<script[^>]*?>[\s\S]*?</script>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<style[^>]*?>[\s\S]*?</style>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<(.[^>]*)>", "",RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"([\r\n])[\s]+", "",RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<!--(.*?)-->", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"“", "“", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"”", "”", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"&(.*?)", "", RegexOptions.IgnoreCase)
html = html.Replace("<", "")
html = html.Replace(">", "")
html = html.Replace("\r\n", "")
return html
}
/// <summary>
/// 去除脚本,样式,框架,事件等标记
/// </summary>
public static string DeleteAnyHtmlTag(string html)
{
html = Regex.Replace(html, @"<select[^>]*?>[\s\S]*?</select>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<script[^>]*?>[\s\S]*?</script>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<style[^>]*?>[\s\S]*?</style>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<iframe[^>]*?>[\s\S]*?</iframe>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<link[^>]*?>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @"<input[^>]*?>", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @" id.*?=.*?""[^>]*?""", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @" class.*?=.*?""[^>]*?""", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @" style.*?=.*?""[^>]*?""", "", RegexOptions.IgnoreCase)
html = Regex.Replace(html, @" on.*?=.*?""[^>]*?""", "", RegexOptions.IgnoreCase)
return html
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)