how to set Meta refresh

E

Evertjan.

young sun wrote on 14 sep 2007 in comp.lang.javascript:
Hi , i am trying to set the http-equiv="refresh" at runtime, but can't
get it to work.Have you any ideas:


var meta = document.createElement('meta');
meta.httpEquiv='refresh';
meta.content='2;url=http://groups.yahoo.com/group/IRAN_CS_CE/';
document.getElementsByTagName('head')[0].appendChild(meta);

That seems impossible, as most browsers will have read the meta onload.

and i cant use setTimeout:
setTimeout('window.location="http://s0urc3.com/";', 2000);


works fine here,
but you could get the same page from your browser cashe.

Try:

setTimeout('window.location.reload(true);', 6000);
 
Y

young sun

works fine here,
but you could get the same page from your browser cashe.
Try:
setTimeout('window.location.reload(true);', 6000);


no , i cant use setTimeout
teach me the method for add and remove meta tag
 
S

Stevo

young said:
no , i cant use setTimeout
teach me the method for add and remove meta tag

To quote Evertjan from his first reply:

"That seems impossible, as most browsers will have read the meta onload."

As far as I have interpreted the meta tag situation, it's an instruction
to the browser, and is not part of the HTML DOM, and therefore isn't
scriptable. That's just how I've always thought about it, but it would
be nice to be wrong about that.

You haven't explained why you can't use setTimeout. You're using
JavaScript anyway, so why not?
 
T

Thomas 'PointedEars' Lahn

young said:
Hi , i am trying to set the http-equiv="refresh" at runtime, but can't
get it to work.Have you any ideas:

var meta = document.createElement('meta');
meta.httpEquiv='refresh';
meta.content='2;url=http://groups.yahoo.com/group/IRAN_CS_CE/';
document.getElementsByTagName('head')[0].appendChild(meta);

Appending the element might work, but it is even more unlikely to work
as supposed than writing the `meta' element with document.write().

Nothing guarantees that such content, iff it is generated, is re-parsed.
Even if there was a guarantee that the element was supported this way,
which there is not.
and i cant use setTimeout:
setTimeout('window.location="http://s0urc3.com/";', 2000);

Then you would be out of luck. Why do you think you can't do that?

Why do you want to do this anyway?


PointedEars
 
Y

young sun

young sun wrote on 14 sep 2007 in comp.lang.javascript:
Hi , i am trying to set the http-equiv="refresh" at runtime, but can't get it to work.Have you any ideas:
var meta = document.createElement('meta');
meta.httpEquiv='refresh';
meta.content='2;url=http://groups.yahoo.com/group/IRAN_CS_CE/';
document.getElementsByTagName('head')[0].appendChild(meta);
and i cant use setTimeout:
setTimeout('window.location="http://s0urc3.com/";', 2000);
Randy Webb said the following on 9/14/2007 5:07 AM:
document.write the meta tag.

=================================================================

with "document.write" i can add meta tag in document but i dont know
how i can remove Meta refresh and my page not refresh
 
T

Thomas 'PointedEars' Lahn

young said:
with "document.write" i can add meta tag in document but i dont know
how i can remove Meta refresh and my page not refresh

You can not.


PointedEars
 
L

Lee

young sun said:
young sun wrote on 14 sep 2007 in comp.lang.javascript:
with "document.write" i can add meta tag in document but i dont know
how i can remove Meta refresh and my page not refresh

Why should anybody waste time on your problem if you won't tell
us why you've decided that you can't use setTimeout()?


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,083
Latest member
SylviaHarr

Latest Threads

Top