Executing Javascript From A Menu Option

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
wwilliam
Beginner
Beginner
Posts: 6
Joined: Tue Sep 23, 2003 2:43 pm

Executing Javascript From A Menu Option

Post by wwilliam »

I am using IE6 exclusively for this app and I have the following line in one of my submenus:

aI("text=ADR - Court Ops;url=javascript:window.open('http://webcontent.courtnet.org/w1_www/o ... enubar=yes');");


It executes fine and opens the seperate browser window and displays the correct page.

The problem that occurs, is that my page in the other browser window goes away and is replaced by a page that just says "[object]".

Does the syntax of this menu option need to be adjusted ??

Thanks.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Got a URL we can look at?

You may have to escape the quotes with a \ .
John
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Pull the javascript function call out of the menu item and call a simpler function. In that simpler function, do the window.open(). The reason I think this happens is because window.open returns a window object reference (which can be used in later code to determine if the window was successfully loaded). I believe the menu is trying to get your page to navigate to this 'window object reference'. In my example below, I defined winPop right after the drawmenus function call, but you can define it anywhere, in another file, in the head of your page, whereever. And note, you could make your winPop function parameterized, so that you could pass in a URL and thats where the pop up would navigate to.

Code: Select all

.....
aI("text=ADR - Court Ops;url=javascript:winPop();"); 
}

drawMenus();

function winPop()
{
  ///the line below should be one line, I chopped it up for the forum
  window.open('http://webcontent.courtnet.org/w1_www/oca/ct_ops/adr.htm', '
UBS','width=800,height=600,resizable=yes,
scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes');
}
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
wwilliam
Beginner
Beginner
Posts: 6
Joined: Tue Sep 23, 2003 2:43 pm

Thanks !!

Post by wwilliam »

That worked great !!!
Post Reply