【发布时间】:2018-02-04 15:48:44
【问题描述】:
我希望 jquery 找到并更改您正在访问的当前 URL 并加载新 URL。假设 jquery 应该在单击时将当前的“index.html”更改为“indexalt.html”,然后加载它。我的想法是使用 document.URL 来获取当前 URL,然后在末尾切掉“.html”并将例如“alt.html”添加到字符串中。我对 jquery 很陌生,并且无法正常工作。我的脚本中可能会有很多错误:
$("#contact").on('click', function() {
var url=document.URL(str.slice(-7));
.load("url +"alt.html"");
如果有人能告诉我如何做以及如何正确地写下来,我将不胜感激。谢谢!
【问题讨论】:
-
window.location = window.location.slice(0,-5) + 'alt.html' -
document.URL ???
标签: javascript jquery string url slice