I'm creating a function in javascript
that is activated by an onclick
and I just need a simple line of javascipt
code to link to another html page.
<area shape="rect" coords="78,348,182,395" onclick="nextquestion">
user clicks on that area
function nextquestion(){
window.location="contact.html";
}
links to this function
Why don't use <area .... href="" />
? Href is valid for area tag
You are not executing the function in this code:
<area shape="rect" coords="78,348,182,395" onclick="nextquestion">
nextquestion
only stays there as a unused variable pointing to the function.
Use nextquestion()
to actually execute the function:
<area shape="rect" coords="78,348,182,395" onclick="nextquestion()">
You'd want to change your onclick to call the function, in JS this requires a set of parentheses after the name of the function like:
<area shape="rect" coords="78,348,182,395" onclick="nextquestion();">
Then in your JS
function nextquestion() {
window.location.href = 'contact.html';
}
did you try this ?
<area shape="rect" coords="78,348,182,395" href = 'contact.html'>
or
<area shape="rect" coords="78,348,182,395" onclick="nextquestion()">
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.