PDA

View Full Version : ddsmoothmenu problem



garyw2
10-30-2011, 12:03 PM
1) Script Title: Smooth Navigational Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm

3) Describe problem: I am using this menu very successfully across a website. But I have a set of pages where I am using some javascrpit to enable users to print out instructions from a page. The code opens a new browser preview window that displays just the instructions from the web page, these being defined by the js print code, and a print window .

The problem is that the new browser window does not have any menu included (since I only want to print a selected part of the page) and thus generates an error.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.1; InfoPath.1; .NET CLR 2.0.50727; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Sun, 30 Oct 2011 11:51:14 UTC

Message: 'ddsmoothmenu' is undefined
Line: 144
Char: 1
Code: 0

Is there a way to stop the page looking for a non-existent menu? Some type of additional code or instruction to stop the error?

ddadmin
10-30-2011, 04:20 PM
The exact detection code to add depends on which part of the page is missing inside the print preview window. If it's all the script references except the invocation code of the menu, in other words, this part:


<script type="text/javascript">

ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

Then, to avoid the above code generating the said error when it's called without any of the support JS references in place is to modify it to the below instead:


<script type="text/javascript">

try{
ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

}catch(e){}
</script>

garyw2
10-30-2011, 10:54 PM
Thank you for the information. That change eliminates the error while everything else in the site still works fine.