Bookmarklet to edit current URL

流过昼夜 提交于 2019-11-29 01:07:03

问题


I'm looking for a simple bookmarklet to take the current URL of my website and refresh it with a couple of changes. For example:

  1. Take the current page: http://www.example.com/pages/
  2. and change it to: https://admin.example.com/pages/
  3. then load that new URL.

I tried searching for a bookmarklet that can do this but I couldn't find one. Can anyone point me in the right direction? Even a bookmarklet that does something like this that I can edit to suit my needs.


回答1:


Just change window.location, e.g.

window.location=window.location.toString().replace(/^http:\/\/www\./,'https://admin.')



回答2:


javascript:location=location.href.replace(/http:/g,"https:")



来源:https://stackoverflow.com/questions/2689553/bookmarklet-to-edit-current-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!