[英]onclick and href both in anchor tag
How to do onclick and href both in anchor tag , in javascript. 如何在javascript的锚标记中同时执行onclick和href 。 my code is :
我的代码是:
enter code here
for (l = 0; l < k; l++) {
var tmp1 = searched_headings_filename[l];
var tmp2 = searched_headings[l];
frameDoc.body.innerHTML += '<div style="margin-left:10;"><li class="highlight"><a onclick="highlightSearch();" href="' + tmp1 + '">' + searched_headings[l] + '</a></li></div>';
}
Please help me... 请帮我...
I suppose you want to run some js function on click, and then redirect to whatever is in the href? 我想您想在单击时运行一些js函数,然后重定向到href中的任何内容? Try this
尝试这个
<a href="javascript:YourFunctionName(someParameter);">displayName</a>
Then in js function 然后在js函数
function YouFunctionName(someParameter){
// do your logic
window.location = 'someUrlYouWantToRedirectTo';
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.