
頁面1代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>頁面1</title>
</head>
<body>
<a href="https://bbs.csdn.net/topics/2.頁面2.html" id="page2">前往頁面2</a>
<script>
var page2=document.getElementById("page2");
a.onclick=function(){
window.open("2.頁面2.html","2.頁面2");
}
</script>
</body>
</html>
頁面2代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>頁面2</title>
</head>
<body>
<a href="https://bbs.csdn.net/topics/3-3 編程練習-index" id="page3">回到頁面3</a>
<br>
<input type="button" value="https://bbs.csdn.net/topics/回到頁面1" id="page1"/>
<script>
var page3=document.getElementById("page3");
var page1=document.getElementById("page1");
page3.onclick=function(){
window.open('3-3 編程練習-index.html','3-3編程練習');
}
page1.onclick=function(){
history.go(-1);
}
</script>
</body>
</html>
頁面3代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="button" value="https://bbs.csdn.net/topics/回到頁面1" id="page1">
<input type="button" value="https://bbs.csdn.net/topics/回到頁面2" id="page2">
<script>
var page1=document.getElementById('page1');
var page2=document.getElementById('page2');
page1.onclick=function(){
history.go(-2);//跳轉到頁面1這個沒有實作
};
page2.onclick=function(){
history.go(-1);//跳轉到頁面2這個沒有實作
};
</script>
</body>
</html>
只有頁面3跳轉到頁面2和頁面1沒有實作,不知道是哪寫錯了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/183505.html
標籤:JavaScript
