2015-03-25 59 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));