87,910
社区成员
发帖
与我相关
我的任务
分享
var a = window.confirm("是否要让我跳转")
if(a){
//跳转
}else{
}
<button id="test">test</button>
<div style="display:none; width:100px;height:100px; border:1px solid red;" id="div">
<script>
function $(o){return document.getElementById(o)}
$('test').onclick = function(){
var bool = confirm('显示div吗?');
if(bool){
$('div').style.display = 'block'
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
#div{
position:absolute;
top:600px
}
</style>
</head>
<body>
<input type="button" id="test" value="跳转"/>
<div id="div">
<p>
吉姆·亨森1936年出生于美国密西西比州,他自小喜欢绘画,尤其爱画卡通人物,十多岁时爱上由腹语大师埃德加·伯根主持的电台节目,同时也开始热爱木偶剧,觉得两者同样以说话古灵精怪做卖点,十分有趣。
谷歌logo纪念吉姆·亨森·芝麻街由6个卡通组成,下面有6个按钮,你可以点击随意一个按钮,对应的卡通人物就会动起了,正好6个卡通与按钮与google6个字母相呼应。
Google Doodle会纪念一些伟大的人物,如C元素发现者阿尔伯特·森特·哲尔吉、雕塑大师亚历山大·考尔德等,吉姆·亨森也是google doodle值得纪念的人。
</p>
</div>
<script>
document.getElementById('test').onclick = function(){
var bool = confirm('确定跳转吗?');
if(bool){
document.getElementById('div').scrollIntoView();
}
}
</script>
</body>
</html>