2015-03-25 62 views
0

我想删除javascript:显示外部从href属性javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8'),我只想从href属性获得URL,所以我该如何。删除javascript:显示外部在href

<a style="color:Blue;text-decoration:underline;" href="javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3A779')" class="cmn" id="ctl00_cntPlcHld1_lstvwSurveys_ctrl14_hlsurvey">View</a> 

回答

1

这可以帮助你:

var temp = "javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8')"; 
trm = /\((.*)\)/i; 
console.log(temp.match(trm)[1]); 

它会给你的输出:

'http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8' 
+0

我已经发布我的HTML代码,你可以看到这一点。 – user3790176 2015-03-25 06:16:44

+0

接受任何一个答案@ user3790176 – 2015-03-25 06:48:38

1

尝试这样Demo Here

var text = $('a').attr('href'); 
var result = text.replace('javascript:ShowExternal(',''); 

console.log(result.slice(0,-1));