When I click on my button it shows the alert as normal but if i click OK, it won't redirect me to the requested page.
当我点击我的按钮时,它会正常显示警报,但如果我点击OK,它不会将我重定向到请求的页面。
My code says:
我的代码是:
<button onclick="return myFunction('Jane McDonald')" href="people/janemcdonald.html">
and
和
function myFunction(person) {
if (confirm("Do you want to go to " + person + "'s profile?")) {
return true;
} else {
return false;
}
}
The alert shows as normal but if I click OK it doesn't redirect me to the page.
警报显示为正常,但如果我单击OK,它不会将我重定向到该页面。
更多回答
errr href
on a button
?
一个按钮上的href?
How about just writing a normal link?
干脆写一个普通的链接怎么样?
优秀答案推荐
1- Change myFunction
code:
1-更改myFunction代码:
function myFunction(person) {
if (confirm("Do you want to go to " + person + "'s profile?")) {
window.location.href = "people/janemcdonald.html";;
} else {
return false;
}
}
2- Delete href
path fom html
2-从html中删除href路径
<button onclick="return myFunction('Jane McDonald')">Redirect</button>
Now you can confirm ok
and the page will redirect to the new path.
现在您可以确认OK,页面将重定向到新路径。
更多回答
我是一名优秀的程序员,十分优秀!