DOM-5 confirm js跳转
程序员文章站
2024-03-19 22:48:46
...
通过confirm获取
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM练习</title>
</head>
<body>
<input type="button" value="Over Check" onmouseover="MyConfirm();">
<script>
function MyConfirm() {
var ret = confirm("Value Check");
console.log(ret);
}
</script>
</body>
</html>
JS获取跳转网址
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM练习</title>
</head>
<body>
<input type="button" value="Over Check" onmouseover="MyConfirm();">
<script>
function MyConfirm() {
var ret = confirm("Value Check");
console.log(ret);
}
var lk = location.href;
// lk即该html的link
console.log(lk);
// 输出为:
// file:///D:/python/oldboy/DAY13/eg04.html
// 刷新
var lk2 = window.location.href;
console.log('lk2:', lk2);
// 输出为
// lk2: file:///D:/python/oldboy/DAY13/eg04.html
// 刷新
// 目前bug反复刷新
// window.location.reload()
// 跳转至百度
location.href = "http://www.baidu.com"
</script>
</body>
</html>