我正在尝试使用mousedown事件创建一个锚点。
我的代码
for (i = 0; i < userDetails.length; i++) {
var userProfileURL = "http://www.xyz.com/KLMS/UserProfile.aspx?userid=" + userDetails[i][1];
userTable += "<li><a href=\"" + userProfileURL + "\" onmousedown=\"StoreClickedURL(" + userId + ",'" + encodeURI(userInput) + "','" + encodeURI(userDetails[i][3]) + "')\" title='" + userDetails[i][2] + "'>" + userDetails[i][2] + "</a></li>";
}
通过使用FireBug,我检查它显示的锚点
<a href="http://www.xyz.com/PublicProfile.aspx?id=1088" onmousedown="StoreClickedURL(1,'physics','http://www.xyz.com/PublicProfile.aspx?id=1088')">http://www.xyz.com/PublicProfile.aspx?id=1088</a>
它在IE以外的所有浏览器中工作。 在IE中它也显示了我上面提到的相同的样式锚。
但不会转到mousedown事件中声明的函数。
请帮忙
提前谢谢。答案 0 :(得分:2)
试试这个
< a href="javascript:StoreClickedURL(1,'physics','xyz.com/PublicProfile.aspx?id=1088');window.location = 'xyz.com/PublicProfile.aspx?id=1088'">