March 5th, 2013AWM: How can I run a JavaScript command from a menu?
Knowledge Base support case for AllWebMenus, abstracted and stripped of all user’s private info.
Initial Email From: Bob
Initial Email Subject: Execute "Javascript Command" from menu item onclick event
Support Case Month: January 2013
I own AllwebMenus PRO 5.3 build 900.
I checked all the help, and I haven't found an explanation on how to call an in-page javascript function from an AllwebMenus menu item, using the "Javascript Command" feature attached to the item's onclick event. The javascript function I want to call actually resides in the <head> section of my web page like this:
<head>
<!-- header stuff -->
<script type="text/javascript">
function changeContentInfo(newText)
{
document.getElementById('DisplayDate').innerText=newText;
}
</script></head>
I can call this function from anywhere in my web page - a button click or focus event etc. But if I try to call it from the "Javascript Command" entry of an AllwebMenus menu item onclick event, nothing happens.
The "Javascript Command" is entered as: changeContentInfo("Monday");
I sure hope it's possible to call a javascript function that resides on the web page, so I can re-use the call from the AllwebMenus "Javascript Command" feature. I don't want to repeatedly write the same full function details into each "Javascript Command" where I would need it.
I'm experimenting with that neat 'calendar' AWM project, and I was checking that my page could respond to clicking on any day in the calendar. That would mean that I would call my function 31 times for the 31 days in March. So far, no luck.
The page I'm working on isn't on my website yet, because it doesn't work.
Thanks,
Bob
Reply From: Likno Customer Support
Dear Bob,
If your page already has the function, then calling it from AllWebMenus should work directly and without problems:
If this does not work, then I will need you to upload your example on a test-page so that I can check it.
Best Regards,
Kostas
Likno Customer Support
www.likno.com
Create any type of javascript menu (CSS menu, drop-down menu, sliding menu), button, html tree, modal window, tooltip, accordion, tab, scroller, jQuery slider or design for your websites!
Like us on Facebook – Follow us on Twitter
Tags: command, css menu, drop-down menu, event, function, JavaScript, javascript menu, jquery, Menu, onClick, run, sliding menu, website