[thelist] Adding META tag via the DOM if not already present (Javascript)

Dave Stevens evolt at davestevens.co.uk
Wed Jan 30 04:17:39 CST 2008


Christian, Ken & Lee - many thanks.

Evolt strikes again :)

Christian Heilmann wrote:
>> Just include that at the end of the BODY as the head won't be ready if
>> you include it there:
>>
>>     (function(){
>>       var head = document.getElementsByTagName('head')[0];
>>       var content = head.innerHTML;
>>       if(content.indexOf('name="DCSext.wt_m"') === -1 &&
>>          content.indexOf('name="DCSext.wt_maglocale"') === -1){
>>         // can not has metas KTHXBAI
>>         var meta = document.createElement('meta');
>>         meta.name = 'DCSext.wt_maglocale';
>>         meta.content = 'en-uk';
>>         head.appendChild(meta);
>>         // ... and so on ...
>>       }
>>     }());
>>
>> http://icant.co.uk/sandbox/meta.html
>>     



More information about the thelist mailing list