I'm making some examples for javascript; they are not really usable. This one is interesting - it works on Chrome (and other using webkit), and Safari. So can someone suggest any reason why it is not working in the other browsers I've tested?
One possible explanation is that the other browsers does not read the meta tags after the page is loaded, or does not read new added ones.
if (document.createElement) {
var meta = document.createElement('meta');
var metaContent = '2; URL=http://localhost/new.html';
meta.setAttribute('http-equiv', 'refresh');
meta.setAttribute( 'content', metaContent );
document.getElementsByTagName('head')[0].appendChild(meta);
}
Most browsers read the meta tags before processing any Javascript. You can inject new meta tags the way that you are coding it but the browsers themselves will not do anything with the new tags. Though the new metas will be available to other code running on the page that is called after the injection.
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