开发者

Bookmarklet to edit current URL

I'm looking for a simple boo开发者_开发问答kmarklet 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.


Just change window.location, e.g.

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

The full bookmarklet would then be:

javascript:(function() {window.location=window.location.toString().replace(/^http:\/\/www\./,'https://admin.');})()


For example you could replace a part of the string using the replace method with a regular expression.

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

The above will assign the new string value to the location and trigger the page reload.


This one will change the site name

javascript:(function() {document.title=prompt("Enter Page Title");})();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜