| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>测试跳转功能</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- max-width: 600px;
- margin: 50px auto;
- padding: 20px;
- text-align: center;
- }
- button {
- padding: 15px 30px;
- margin: 10px;
- font-size: 18px;
- cursor: pointer;
- background: #409eff;
- color: white;
- border: none;
- border-radius: 5px;
- }
- button:hover {
- background: #66b1ff;
- }
- .info {
- background: #f0f9ff;
- padding: 15px;
- margin: 20px 0;
- border-left: 4px solid #409eff;
- text-align: left;
- }
- .countdown {
- font-size: 24px;
- color: #409eff;
- margin: 20px 0;
- }
- </style>
- </head>
- <body>
- <h1>跳转功能测试</h1>
-
- <div class="info">
- <p><strong>测试说明:</strong></p>
- <p>点击下面的按钮,页面将在3秒后跳转到登录页</p>
- <p>这个测试用于验证 window.location.href 跳转是否正常工作</p>
- </div>
- <button onclick="testRedirect()">测试跳转到登录页</button>
-
- <div id="countdown" class="countdown"></div>
- <script>
- function testRedirect() {
- let seconds = 3;
- const countdownEl = document.getElementById('countdown');
-
- const timer = setInterval(() => {
- countdownEl.textContent = `${seconds} 秒后跳转...`;
- seconds--;
-
- if (seconds < 0) {
- clearInterval(timer);
- countdownEl.textContent = '正在跳转...';
- console.log('执行跳转: window.location.href = "/login"');
- window.location.href = '/login';
- }
- }, 1000);
-
- countdownEl.textContent = `${seconds} 秒后跳转...`;
- }
- </script>
- </body>
- </html>
|