[英]Is there a way to stop a url redirecting using javascript or Jquery?
for example when you click on this flickr url: http://www.flickr.com/photos/caterpiya/5716797477/sizes/h/ 例如,当您单击此flickr网址时: http : //www.flickr.com/photos/caterpiya/5716797477/sizes/h/
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? / sizes / h /更改为/ sizes / l /我如何阻止它进行更改,并且如果转到404则通过Jquery或javascript发出警报?
<script>
function yo(){
var href = "http://www.flickr.com/photos/caterpiya/5716797477/"
href = href+"sizes/h/";
window.open(href);
}
</script>
<button onclick="yo()">open</button>
how about using a global variable? 如何使用全局变量? Something like:
就像是:
<script>
var isUrlClicked = false;
function yo(){
var href = "http://www.flickr.com/photos/caterpiya/5716797477/"
href = href+"sizes/h/";
isUrlClicked = true;
window.open("href");
}
</script>
<button onclick="yo()">open</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.