I'm developing in PHP, using Curl to follow links to their final destination. I occasionally reach a page with a meta tag redirection or a javascript redirection, and want to be smart enough to follow them. If a page has both, which should I follow (i.e., which would fire first)?
Sample meta tag refresh:
<meta http-equiv="refresh" content="0;URL='http://location1.com/'">
Sample javascript refresh:
<script>
window.location.href='http://location2.com/';
</script>
Just created this file ( let's call it test.html
)
<html>
<head>
<meta http-equiv="refresh" content="0;URL='http://location1.com/'">
<script type="text/javascript">
window.location.href='http://location2.com/';
</script>
</head>
<body>
Hello
</body>
</html>
You can copy and save it. Once you open it, you'll be directed to http://location2.com
Do note that if the <script>
tag is not in the <head>
tag, the <meta>
tag gets executed first.
Hexblot's answer is a good idea -- just try it out if you want to see what happens. However, when I did try it out, Chrome went to location2, and IE went to location1. So it seems to be implementation dependent. You might want to have this be a configurable option on your script. In practice, though, any site that has one redirect in a meta tag and a different one in a script, is (a) unlikely, and (b) not coded very well, as they have no idea where you'll end up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With