#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    68
    Rep Power
    14

    Javascript- need to close current window and redirect....


    Im really new to JS...

    when a small window opens, there is a condition when if met, i would like the window to redirect to another link and close itself...

    i want it to redirect into the window which opened itself... not inside itself...

    is this possible without any action event?

    it would be on a page load or something? if this condition is met, then close.me and redirect?

    if possible could someone post sample code?

    it would be greatly appreciated...

    thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    New Zealand
    Posts
    167
    Rep Power
    14

    which condition?


    Hi,

    Um I'm not too sure what you mean by 'if the condition is met' - if you could let me know what you're trying to check for, I'll see if I can write the code for you.

    In the meantime, here's an example that is kind of similar, it uses a function though. The popup redirects and closes if the checkbox is checked.

    -- page1.htm --

    <HTML>
    <HEAD>
    </HEAD>
    <BODY>Original Page (page1.htm)<br>
    <a href="page1.htm" onClick="window.open('popup.htm')">Click here to open new window</a>.
    </BODY>
    </HTML>

    -- popup.htm --

    <HTML>
    <HEAD>
    <script language="javascript">
    function redirect()
    {
    if (document.popupForm.redirectMe.checked)
    {
    window.opener.location = "page2.htm";
    window.close()
    }
    }
    </script>
    </HEAD>

    <BODY>Popup Page (popup.htm)<br>
    <form name="popupForm">
    <input type="checkbox" name="redirectMe" value="redir" onClick="redirect()">If you check this box, the redirect occurs and this window closes.
    </form>
    </BODY>
    </HTML>

    -- page2.htm --

    <HTML>
    <HEAD>
    </HEAD>
    <BODY>Redirect Page (page2.htm)<br>
    <a href="page1.htm">Click here to return to page1.htm</a>.
    </BODY>
    </HTML>

    -- end of script --

    Hope that is of some help... as I say, if you post some more details I'd be happy to give it another go.



    Jen

IMN logo majestic logo threadwatch logo seochat tools logo