location 是 JavaScript 中最有用的 BOM 对象之一,它提供了当前文档信息和一系列导航功能。
任务1: 使用 JS 使当前页面跳转到 https://www.github.com
答案
window.location = 'https://www.github.com'; // 方法1
location.href = 'https://www.github.com'; // 方法2
location.assign('https://www.github.com'); // 方法3
任务2: 将 URL 修改为 https://www.github.com#issue1
答案
location.hash = 'issue1';
任务3: 将 URL 修改为 https://www.github.com?user=wingmeng
答案
location.search = 'user=wingmeng';
任务4: 将 URL 修改为 https://www.gitee.com
答案
location.hostname = 'www.gitee.com';
任务5: 将 URL 修改为 https://www.gitee.com/market
答案
location.pathname = 'market';
任务6: 将 URL 修改为 https://www.gitee.com:8080/market
答案
location 是 JavaScript 中最有用的 BOM 对象之一,它提供了当前文档信息和一系列导航功能。
任务1: 使用 JS 使当前页面跳转到
https://www.github.com答案
任务2: 将 URL 修改为
https://www.github.com#issue1答案
任务3: 将 URL 修改为
https://www.github.com?user=wingmeng答案
任务4: 将 URL 修改为
https://www.gitee.com答案
任务5: 将 URL 修改为
https://www.gitee.com/market答案
任务6: 将 URL 修改为
https://www.gitee.com:8080/market答案