gpt4 book ai didi

Why wont my button redirect to another page after a confirmation alert?(为什么我的按钮在收到确认警报后不会重定向到另一个页面?)

转载 作者:bug小助手 更新时间:2023-10-25 22:50:05 27 4
gpt4 key购买 nike



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?

Does this answer your question? How do I create an HTML button that acts like a link?

这回答了你的问题吗?如何创建起到链接作用的HTML按钮?

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,页面将重定向到新路径。


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com