Skip to content Skip to sidebar Skip to footer

Javascript | Link/bookmarklet To Replace Current Window Location

I often work with three variations of a web page, 1) a dev url, 2) a preview/staging url, and 3) and live url. I would like to create a link (bookmarklet?) that I can then add to

Solution 1:

Your code should work.

But try this

javascript:(function(){var loc=location.href;loc=loc.replace('dev.mysite.com/cf#/content/www/','preview2.mysite.com/'); location.replace(loc)})()

Remember to copy this into the URL of a real bookmark - I normally send people a web page they can drag from so the quotes are indeed important:

<ahref="javascript:(function(){var loc=location.href;loc=loc.replace('dev.mysite.com/cf#/content/www/','preview2.mysite.com/'); location.replace(loc)})()">ReplaceUrlBM</a>

Post a Comment for "Javascript | Link/bookmarklet To Replace Current Window Location"