Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Redirecting main parent window with JavaScript

Redirecting main parent window with JavaScript

Scheduled Pinned Locked Moved Web Development
javascriptcomhelpdiscussion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Ingles
    wrote on last edited by
    #1

    I'm trying to get some JavaScript so that a number of pop-ups can figure out the parent that spawned them all, close themselves and re-direct the main parent. It works as I want (if it's coming from a pop-up then it'll spawn a new window), but, if I click to show the first pop-up, then close the main parent window, and continue through to the page that executes the below code, it throws up an error:

    function findWindow()
    {
    var currentWnd;
    currentWnd = self;

    while (currentWnd.opener != null  && !currentWnd.opener.closed)
    {
    	var oldWnd = currentWnd;
    	currentWnd = currentWnd.opener;
    	oldWnd.close();
    	
    }
    
    if (!WindowIsPopup(currentWnd))
    {
    	currentWnd.document.location.href='http://www.microsoft.com';
    } else {
    	// It's a pop-up, so close it and open a new page altogether.
    	open('http://www.theregister.co.uk');
    	currentWnd.close();
    }
    

    }

    Basically, I want to be able to do a check to find out whether I've reached the main parent window, and if it's not open, spawn a new one etc. If anyone has any suggestions, or has done this kind of thing before I'd appreciate their thoughts. Thanks, -- Paul "Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office." - David Brent, from "The Office" MS Messenger: paul@oobaloo.co.uk Download my PGP public key

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups