【发布时间】:2018-04-10 09:27:41
【问题描述】:
我正在尝试将两个小书签合并为一个,以便它
删除所有 url 参数(如果有)
从一个 url 重定向到子域。
例子:
来自
http://www.justsomeurl.com/cat/article123?umt=sometimes-theres-a-parameter
到
http://cms.justsomeurl.com/.admin/something/cat/article123
我有两个单独的小书签可以做到这一点,但我没有设法将它们结合起来。
javascript:location.href = location.href.substring(0,location.href.lastIndexOf("?"));
和
javascript:(function() {window.location=window.location.toString().replace(/^https:\/\/www\.justsomeurl.com/,'http://cms.justsomeurl.com/.admin/');})()
我怀疑第 1 步和第 2 步之间需要延迟。
我已经尝试过这个(以及许多组合),但似乎只选择了第二个功能:
javascript:
function removeParameter(){ location.href = location.href.substring(0,location.href.lastIndexOf("?"));} ;
(function replace() {window.location=window.location.toString().replace(/^https:\/\/www\.justsomeurl.com/,'http://cms.justsomeurl.com/.admin/');})();
感谢任何帮助!谢谢!
【问题讨论】:
标签: javascript content-management-system bookmarklet url-parameters