Results 1 to 5 of 5

Thread: simple refresh

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181

    simple refresh

    i have this code


    Code:
    <script language="JavaScript" type="text/JavaScript">
    function RefreshMainWindow() {
     window.opener.location.reload();
     window.close()
    }
    </script>
    
    //called by 
    
    <META HTTP-EQUIV="refresh" CONTENT="5; RefreshMainWindow();">

    am i not allowed to call a method in a refresh block? how can i do something like this..

    when the script runs, every 5 seconds, the parent refreshs, but the child windows (that this script is on) doesn't clse like it's supposed to, it refreshes too..

    --770

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    when you open the window open it with a var name...

    Code:
    var newWin = window.open('page2.htm');
    ... the try doing newWin.close() instead.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yes you can't use scripting in a meta refresh, I think you're looking for setTimeout():

    Code:
    <script type="text/javascript"><!--
    window.setTimeout('RefreshMainWindow();', 5000);
    //--></script>
    Think that should work.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181
    i'm new to JS, so not exactly sure where to put the script Rick Bull gave, and how to call it....

    or how to give the opening window a variable name...
    this is how i'm currently opening a new window

    Code:
    target="_blank"
    --770

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    You can put the code I gave either in the <head> section or the <body> section. I'd go with the head.

    target="_blank" is find if you're just using standard links (which is better as not every browser supports JS). Other wise you can use javascript something like
    Code:
    var newWin = window.open('page.html', 'windowName');
    Then you can use newWin with Javascript (e.g. newWin.close()) and target the new window with standard links like <a href="#" target="windowName">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width