I am trying to generate a help menu within my web application and would to like to place a mailto link within the menu to open the clients default mail program and fill in the to: and subject fields. I am creating the entire menuToolbar dynamically from a bound bean and can successfully create the link but I'm not getting the behaviour I want! ie.
HtmlToolBarGroup tmpTBGroup;
tmpTBGroup = (HtmlToolBarGroup) app.createComponent(HtmlToolBarGroup.COMPONENT_TYPE);
tmpTBGroup.setLocation("right");
HtmlDropDownMenu helpMenu;
HtmlMenuItem tmpMenuItem;
helpMenu = (HtmlDropDownMenu) app.createComponent(HtmlDropDownMenu.COMPONENT_TYPE);
helpMenu.setValue("Help");
tmpMenuItem = (HtmlMenuItem) app.createComponent(HtmlMenuItem.COMPONENT_TYPE);
tmpMenuItem.setSubmitMode("client");
tmpMenuItem.setValue("Help Request");
tmpMenuItem.setOnclick("mailto:help@omniuscomputing.co.uk?subject=Website Help Request");
helpMenu.getChildren().add(tmpMenuItem);
tmpTBGroup.getChildren().add(helpMenu);
creates a menu item correctly but it does nothing when clicked.
If I use -
tmpMenuItem.setOnclick("window.open(\"mailto:help@omniuscomputing.co.uk?subject=Website Help Request\")");
then IE9 opens a new window and then tries to render the mailto link which does open the default email program but it leaves a blank window wich just looks rubbish! Any help would be appreciated.
Hi Chris,
Use location.href = 'mailto:....'