日期:2014-05-16  浏览次数:20507 次

如何去掉JavaScript下的超链接?
如:<a href='javascript:ShowProductDetail("<%# Eval("ProductGuid")%>")'><%# Eval("ProductName")%></a>
  我现在想通过js去掉<a href='javascript:ShowProductDetail("<%# Eval("ProductGuid")%>")'>
  保留<%# Eval("ProductName")%> 请问各位大虾,如何实现?


------解决方案--------------------
JScript code
var s='<a href=\'javascript:ShowProductDetail("<%# Eval("ProductGuid")%>")\'><%# Eval("ProductName")%></a>';
alert(s.replace(/<\/?a[^>]*>/gi,''));

------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function init(){
var a=document.links;
for(var i=0;i<a.length;i++){
var par=a[i].parentNode;
var p=document.createElement("font");
p.innerHTML=a[i].innerHTML;
par.replaceChild(p,a[i]);
}
}
window.onload=init;
</script>
</head>

<body>
<a href='javascript:ShowProductDetail("<%# Eval("ProductGuid")%>")'><%# Eval("ProductName")%></a>
</body>
</html>
这样??