JavaScript.CoolDev.Com Support Forums

Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Javascript links in the menu

 
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu
Author Message
Dewang



Joined: 29 Oct 2003
Posts: 2

PostPosted: Wed Oct 29, 2003 7:02 am    Post subject: Javascript links in the menu Reply with quote

Hi,
I am trying to add "javascript:" links to my menu items. The link works fine - my function is called. The function opens a popup window.

However in the main window where my menu is defined, I get a blank page with [Object] written. I made my function return false after opening the popup, but that just makes the page dispaly 'false' instead of [Object].

Is there any way to stop the page from trying to load that blank page and just call the javascript function?

Snippet of my MENU_ITEMS:
Code:

            {code:"JavaScript Test", url:"javascript:OpenInNewWindow(\'test.htm\')", "format":{"image":"img/home.gif", "oimage":"img/ohome.gif", "style":STYLE_BOTT}}


Thanks,
-Dewang
Back to top
undisclosed
Guest





PostPosted: Wed Oct 29, 2003 12:34 pm    Post subject: Reply with quote

http://javascript.cooldev.com/scripts/coolmenu/docs/

read that, and use the target tag to open a new window
Back to top
Dewang



Joined: 29 Oct 2003
Posts: 2

PostPosted: Wed Oct 29, 2003 12:43 pm    Post subject: Reply with quote

Hi,

Thanks for the reply. My main problem is not of the target. I have read the docs, and would have used target=_blank if that was what I needed.

I need to call a Javascript function when a menu item is clicked - window.open is just one example. window.open does provides a lot more functionality than specifying a target.

But my main requirement is to be able to call a javascript function. As per the docs -
"url" URI value for HREF attribute of A tag for menu item. Is not required. May contains javascript function calls with prefix "javascript:"

Now this works. But like I mentioned, the problem is that sets the content of the page that has the menu to an empty page with just [object] or false, depending on whether or not I make my function return false. Sad

Hoping for a solution...

-Dewang
Back to top
Walt
Guest





PostPosted: Thu Oct 30, 2003 11:39 pm    Post subject: ME TOO!!! Reply with quote

I run a number of functions in my IE only app (i.e. modalDialog(), newWindow(), setCookie(), etc) when executing links. Where would I put the called function to have it accessable by the menu? I a ver at the top of page, and know it's set because I confirmed w/ alart, but when I execute the link it comes up as "undefined".

Thanks, Walt

Dewang wrote:
Hi,

Thanks for the reply. My main problem is not of the target. I have read the docs, and would have used target=_blank if that was what I needed.

I need to call a Javascript function when a menu item is clicked - window.open is just one example. window.open does provides a lot more functionality than specifying a target.

But my main requirement is to be able to call a javascript function. As per the docs -
"url" URI value for HREF attribute of A tag for menu item. Is not required. May contains javascript function calls with prefix "javascript:"

Now this works. But like I mentioned, the problem is that sets the content of the page that has the menu to an empty page with just [object] or false, depending on whether or not I make my function return false. Sad

Hoping for a solution...

-Dewang
Back to top
Guest
Guest





PostPosted: Wed Dec 17, 2003 9:35 pm    Post subject: Possible solution Reply with quote

Add "void( )" around the javascript function call. For example:

{'code':'Menu item', 'url':"javascript:void(window.open('test.html', 'window1', 'width=400,height=300'))", ...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu All times are GMT
Page 1 of 1