For a HTML button element i want to bind the below onclick event
<a class="btn btn-sm btn-bitbucket" id="test" onclick="document.location.href='https://192.22.32.101/V0_3_4/cgi-bin/config.cgi'">
The above one works fine and the cgi got executed perfect . But the requirement is i want to replace " https://192.22.32.101/V0_3_4/cgi-bin/config.cgi " with a varible since this is dynamic . Can someone provide the java script. Like the below.
HTML
<a class="btn btn-sm btn-bitbucket" id="test"> .
JAVA SCRIPT
document.getElementById("test").onclick = "document.location.href="HOST_CGI_PATH""; (I am facing difficulties defining the correct quotes)
I am doing this binding in document ready function.Here the HOST_CGI_PATH is a javascript variable refers to the actual path.
Thanks
Do
document.getElementById("test").onclick = function(){
document.location.href=HOST_CGI_PATH;
});
您太复杂了:
document.getElementById("test").href = HOST_CGI_PATH;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.