javascript - 如何替换并加载用户输入的新网址

标签 javascript

如何替换整个 URL,然后使用用户在提示中输入的新 URL 替换并加载它,此时我已经完成了

var website = prompt("enter a website");

document.location.href.replace = 网站;

我尝试过一次不同的方法,但它添加了我已有的 URL。我想要替换整个网址 the url that needs to replaced

谢谢

最佳答案

试试这个:

var website = prompt("enter a website");
window.location.href = website;

关于javascript - 如何替换并加载用户输入的新网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48571111/

相关文章:

javascript - 为什么 getBoundingClientRect 在 IE8 中很慢?

javascript - 在 javascript 中创建自动幻灯片图像的方法是什么?

javascript - Deobfuscating Javascript - 如何替换随机变量名?

javascript - Google Gears 和 jQuery 创建 managedStore 的问题

javascript - 发送电子邮件函数: error because of formulas in blank rows

JavaScript 动画性能

javascript - 如何在 jQuery 和 CasperJS 中禁用超时

javascript - Mithril : prevent full application reload on submit

javascript - 检索 php 变量中的 javascript 变量

javascript - 在 D3 js 中沿着给定方向移动一条线?