Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is It possible to dynamically remove meta refresh tag from header using jQuery?

I have meta tag in Header like that..

<meta http-equiv='refresh' content='0;url=http://stackoverflow.com/'>

is it possible to Remove it Dynamically using jQuery ?

like image 899
DBTutor Avatar asked Sep 16 '11 06:09

DBTutor


2 Answers

In order to implement different behavior when scripting support is enabled you should include the meta refresh between <noscript> tags, like so

<noscript>
    <meta http-equiv='refresh' content='0;url=http://stackoverflow.com/'>
</noscript>

and implement the desired functionality after loading the DOM. Something along the lines of:

$(window).load(function() {
    // here
})

Confirmed working on the latest Firefox version

like image 137
mgois Avatar answered Oct 12 '22 23:10

mgois


No.

First, loading the jQuery library would take way too long so you'd have to do it with straight Javascript if anything.

Second, even if the meta had an id and you placed the simplest JS snippet immediately after it:

<meta id="stopMe" http-equiv='refresh' content='0;url=http://stackoverflow.com/'>
<script>
    var meta = document.getElementById('stopMe');
    meta.parentNode.removeChild(meta);
</script>

it would still be too late because the content=0 in the meta means to execute the refresh immediately so the script will never be executed. If you placed the script before the meta it wouldn't work because there would be no DOM element yet to reference.

like image 25
mVChr Avatar answered Oct 13 '22 00:10

mVChr