PDA

View Full Version : Inhibit/Remove MetaTag using JavaScript



Eternal_Nighmar
01-30-2011, 04:55 AM
Hello everybody, new here. I'm a complete JavaScript newbie, all I know is some HTML, CSS and little jQuery. Don't be so harsh :P

I own and run a forum on a free software called Forumotion. Since these people like getting a lot of revenue, they added a metatag that makes IE8 work like IE7. Here it is.


<!-- BEGIN meta_emulate_ie7 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<!-- END meta_emulate_ie7 -->

This works on only some pages on my forum. However, since we use a lot of CSS and JavaScript codes that IE7 doesn't support (but IE8 does), these pages are completely screwed up.

Since they don't offer template editing for some versions (in which this tag can be found), I cannot simply delete this tag (unfortunately).

I have come here to ask if there's any way to inhibit, remove, delete and destroy that stupid metatag which is screwing my forum up using JavaScript, jQuery, AJAX, or any other way (except PHP, since it's disallowed...) to do so.

Any ideas? Any help will be absolutely appreciated. Thanks a bunch. :D:D

Philip M
01-30-2011, 09:21 AM
META tags with an HTTP-EQUIV attribute are equivalent to HTTP headers. Typically, as her, they control the action of browsers, and may be used to refine the information provided by the actual headers.

AFAIK it is not possible to change or delete such a tag after it has been loaded. In any case to do so may well be contrary to the terms and conditions of the service.

You say "I own and run a forum on a free software called Forumotion.". Remember that cheese in a trap is always free. :D


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Eternal_Nighmar
01-30-2011, 04:41 PM
Hello, Philip M, and thanks for your prompt reply. :D

I've been told by one of this software's technicians/developers that I can remove it (so this wouldn't be against their ToS), but turns out that, since I can't edit templates, it's not that easy.



It is not possible to change or delete such a tag after it has been loaded.

That stinks. :/ I've been given a code elsewhere and was wondering if it could help, it can be found here (http://yourjavascript.com/01103311131/RemoveIE.js). I haven't been able to get it to work yet, though.

If anyone thinks it is possible to get rid of this tag (I really hope it is), please share your comment. Thanks :D

Philip M
01-30-2011, 05:23 PM
That code seems to work to change the content - in IE at least.


var m=document.getElementsByTagName('meta');

for(var c=0;c<m.length;c++) {
alert (m[c].content); // for testing
if(m[c].content=='IE=EmulateIE7') {
m[c].content='';
alert (m[c].content); // for testing
}
}

But - the meta tag has already loaded and executed before the script has run so changing the content afterwards has no effect.

Eternal_Nighmar
01-30-2011, 07:26 PM
Then, to make a long story short, it's absolutely not possible to make it useless? Will I have to use CSS and JavaScript hacks for IE7?

Philip M
01-30-2011, 08:42 PM
Then, to make a long story short, it's absolutely not possible to make it useless? Will I have to use CSS and JavaScript hacks for IE7?

No. Definitely not possible. As I say, remember that the cheese in a trap is always free. :D

Eternal_Nighmar
01-30-2011, 09:42 PM
LOL, okay, thanks for your help. Can I ask how for a few IE7 CSS hacks here then, or should I open up a new topic elsewhere?

Newbies... :P

Eternal_Nighmar
02-01-2011, 12:51 AM
You can consider this solved. I took the time to write IE7 hacks and everything is on place now.

Thanks for your great help, great forum. Keep up the great work!