JavaScript.CoolDev.Com Support Forums
Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com
| Author |
Message |
Dewang
Joined: 29 Oct 2003 Posts: 2
|
Posted: Wed Oct 29, 2003 7:02 am Post subject: Javascript links in the menu |
|
|
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
|
|
| Back to top |
|
 |
Dewang
Joined: 29 Oct 2003 Posts: 2
|
Posted: Wed Oct 29, 2003 12:43 pm Post subject: |
|
|
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.
Hoping for a solution...
-Dewang |
|
| Back to top |
|
 |
Walt Guest
|
Posted: Thu Oct 30, 2003 11:39 pm Post subject: ME TOO!!! |
|
|
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.
Hoping for a solution...
-Dewang |
|
|
| Back to top |
|
 |
Guest Guest
|
Posted: Wed Dec 17, 2003 9:35 pm Post subject: Possible solution |
|
|
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 |
|
 |
|
|