javascriptbookmarkletlocation-href

Bookmarklet to prepend Address bar string


I need to prepend window.location.href in place.

Use case: Expedite single-webpage tasks by actively updating the Address bar for the User.

UX:

  1. Address Bar displays Location.
  2. User clicks Bookmarklet.
  3. Bookmarklet updates Location to knownString/Location.
  4. Bonus: Browser automatically posts new Location for User.

Example: Original URI: http://domain1.tld1/default.htm Modified URI: https://subdomain.domain2.tld2/http://domain1.tld1/default.htm

Hours of fruitless searches and tweak fails of appending/swapping suggestions have me beat.


Solution

  • This should do what you're looking for:

    javascript:window.location.href="https://subdomain.domain2.tld2/"+window.location.href