Is there a way to stop a url redirecting using javascript or Jquery? <p>for example when you click on this flickr url: <a href="http://www.flickr.com/photos/caterpiya/5716797477/sizes/h/" rel="nofollow">http://www.flickr.com/photos/caterpiya/5716797477/sizes/h/</a></p> <p>The /sizes/h/ changes to /sizes/l/ how can I stop it from making this change and be given an alert through Jquery or javascript if it goes to a 404?</p> <pre><code>&lt;script&gt; function yo(){ var href = "http://www.flickr.com/photos/caterpiya/5716797477/" href = href+"sizes/h/"; window.open(href); } &lt;/script&gt; &lt;button onclick="yo()"&gt;open&lt;/button&gt; </code></pre>