为了账号安全,请及时绑定邮箱和手机立即绑定

选择警报框选项时页面跳转

选择警报框选项时页面跳转

函数式编程 2021-05-11 21:31:20
我希望根据用户在警报框中的选择,将用户页面跳转到我网站的已定位部分。当警报框弹出时,如果他们确认自己拥有iPhone(这只是信息性的,设备确实没有关系),则应说“很酷”并留在原处,因为iPhone信息从顶部开始。但是,如果它们取消了,我希望它们被页面跳转到Android信息开始的页面底部。我一直在浏览堆栈溢出和其他各种站点,但是找不到解决该问题的方法,但是如果我错了,请原谅。<!--the Javascript function -->function Question() {var x=window.confirm("You have an iPhone right???")if (x)window.alert("Good!")elsewindow.alert("Here is info for your device type!")}<!-- the html im looking to jump to --><h2 id = galaxyInt><a id = "SamsungStart">Samsung Galaxy Mobile Security</a></h2>我希望不单击警报框确认,否则else语句会将用户从页面跳到正确的部分。
查看完整描述

1 回答

?
蓝山帝景

TA贡献1843条经验 获得超7个赞

使用window.location.href =“ #SamsungStart”; 链接到您要访问的ID。


<!--the Javascript function -->


function Question() {

var x=window.confirm("You have an iPhone right???")

if (x)

window.alert("Good!")

else

window.location.href = "#SamsungStart";

}

Question();

#top{

width:100%;

height:300px;

float:left;

background-color:blue;

}

.container2{

width:100%;

height:400px;

float:left;

background-color:green;


}

#galaxyInt{

width:100%;

float:left;


}

#SamsungStart{

width:100%;

float:left;

}

<!-- the html im looking to jump to -->


<div id = "top"></div>




<div class="container2">

<h2 id = "galaxyInt"><a id = "SamsungStart">Samsung Galaxy Mobile 

Security</a></h2></div>


查看完整回答
反对 回复 2021-05-27
  • 1 回答
  • 0 关注
  • 156 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信