SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript windowing

    I have a page with several pop-up menus, each containing links to other sites. I call a function popLink() from the onChange handler in the <select> form element. This is the guts of popLink():

    Code:
    if (eval ("typeof(" + name + "Win) != 'undefined'"))	{
    			 eval (name + "Win" + ".focus()");
    } else {
    		 	eval (name + "Win" + " = window.open(url,name,win_attr)");
    }
    I use eval() because I want each window to have it's own name that I can reference to focus() it when the user chooses that same option from one of the pop-up menus. The problem is what happens if the user has closed one of the spawned windows and then reselects an option from the pop-up. The first test passes but the new object is a String not a window. How do I see if a window exists but still using eval()? Simply doing the following

    Code:
        if (eval (name + "Win"))
    always returns true presumably because it's testing whether it can evaluate the expression.

    I know there is a way to do this but I guess I am too retarded to figure it out. Any help would be greatly appreciated.
    <<< johnny chidiac
    johnnydaboy@mac.com

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try

    Code:
    if (eval (name +".closed == true") ) {
    ..
    }
    to check if the window name was closed.

    Paul

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, welcome to Sitepoint forums johnnydaboy!!

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks Paul

    That worked perfectly!

    And thanks for the welcome, too!
    <<< johnny chidiac
    johnnydaboy@mac.com


Bookmarks

Posting Permissions

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