Some browsers do not recognize meta tags added through Javascript

I am doing some examples for javascript; they cannot be used. This is interesting - it works on Chrome (and others using webkit) and Safari. So can anyone suggest any reason why it doesn't work in other browsers that I tested?

One possible explanation is that other browsers don’t read the meta tags after loading the page or they don’t read the new ones added.

   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);
   }
+3
source share
2 answers

Javascript. , , . , , .

+3

- 512 , . , DOM, .

0

Source: https://habr.com/ru/post/1770808/


All Articles