how to set Meta refresh

Discussion in 'Javascript' started by young sun, Sep 14, 2007.

  1. young sun

    young sun Guest

    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);
    young sun, Sep 14, 2007
    #1
    1. Advertising

  2. young sun

    Evertjan. Guest

    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);


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Sep 14, 2007
    #2
    1. Advertising

  3. young sun

    young sun Guest

    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
    young sun, Sep 14, 2007
    #3
  4. young sun

    Stevo Guest

    young sun wrote:
    >> Try:
    >> setTimeout('window.location.reload(true);', 6000);

    > 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?
    Stevo, Sep 14, 2007
    #4
  5. young sun

    Stevo Guest

    Randy Webb wrote:
    > young sun said the following on 9/14/2007 5:07 AM:
    >> 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

    >
    > document.write the meta tag.


    I guess I was wrong then. Cool :)
    Stevo, Sep 14, 2007
    #5
  6. young sun wrote:
    > 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
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
    Thomas 'PointedEars' Lahn, Sep 14, 2007
    #6
  7. young sun

    young sun Guest

    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
    young sun, Sep 15, 2007
    #7
  8. young sun wrote:
    > 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
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
    Thomas 'PointedEars' Lahn, Sep 15, 2007
    #8
  9. young sun

    Lee Guest

    young sun said:
    >
    >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:


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


    >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()?


    --
    Lee, Sep 15, 2007
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond

    server-side timer vs. meta refresh

    Jim Hammond, Oct 24, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    5,887
    mikeb
    Oct 27, 2003
  2. Nym Pseudo

    META NAME and META HTTP-EQUIV

    Nym Pseudo, Sep 26, 2003, in forum: HTML
    Replies:
    1
    Views:
    528
    =?iso-8859-1?Q?brucie?=
    Sep 26, 2003
  3. Duane Johnson

    Meta methods to govern meta data?

    Duane Johnson, Oct 25, 2005, in forum: Ruby
    Replies:
    6
    Views:
    220
    Adam Sanderson
    Oct 28, 2005
  4. Erik Veenstra

    Meta-Meta-Programming

    Erik Veenstra, Feb 7, 2006, in forum: Ruby
    Replies:
    29
    Views:
    349
    Erik Veenstra
    Feb 8, 2006
  5. Erik Veenstra

    Meta-Meta-Programming, revisited

    Erik Veenstra, Jul 21, 2006, in forum: Ruby
    Replies:
    21
    Views:
    420
    Erik Veenstra
    Jul 25, 2006
Loading...

Share This Page