close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Calling a JavaScript function from a menu item

Thread began 11/29/2010 12:06 pm by markhaynes75235 | Last modified 12/14/2010 12:27 pm by markhaynes75235 | 5460 views | 4 replies |

markhaynes75235

Calling a JavaScript function from a menu item

I'm trying to implement some features using CSS MenuWriter but have found that in some instances, when using the menu item to call a script, the script does not run. One instance I have involves the CMS Font Sizer script. Instead of using hyperlinks, I want to use a CSS MenuWriter menu to call the script that resizes the text on the page. When I use simple hyperlinks the text resizes fine, but when I call the script from a menu it does not work. I've tried putting the script in the menu.php as well as in the same <div> and the <head> (shouldn't matter). So I'm wondering if anyone else has used CSS MenuWriter menus to call a JavaScript function.

The second instance involves IE (7 & 8). I'm calling the Shadowbox script to bring up a page in a shadowbox from a CSS MenuWriter menu. This works fine in all other browsers (Firefox, Safari, Google Chrome) but in IE the browser just navigates to the page, ignoring the rel="shadowbox....etc." in the <a> tag.

Thanks in advance for any insight as to how to fix this!

Sign in to reply to this post

Jason ByrnesWebAssist

can you send a link where i could see the issue to debug the cause.

Sign in to reply to this post

markhaynes75235

Calling a JavaScript function from a menu item

Hi Jason:

I've got the site set up on an internal system and I'm working with IT to see if I can share it out to authorized parties.

The script in live code view shows up like this:

<script type="text/javascript">
<!--
// Change Text Size by Community MX
// Copyright 2007, All rights reserved
function CMXwriteCookie(n,i,t){
var ep="";if (t){d = new Date();d.setTime(d.getTime()+(t*86400000));
ep = "; expires="+d.toGMTString();}document.cookie = n+"="+i+ep+"; path=/";
window.location.href = window.location.href;
}
function CMXreadCookie(n){
eq = n+"=";ca = document.cookie.split(';');for(var i=0;i<ca.length;i++) {
c=ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(eq) == 0) return c.substring(eq.length,c.length);}return null;
}
fSize=(CMXreadCookie('fSize') == null)?11:CMXreadCookie('fSize');

document.write('<style type=\"text/css\">');
document.write('.varText {font-size:'+fSize+'px;}');
document.write('<\/style>');
//--!>
</script><style type="text/css">.varText {font-size:11px;}</style>
<script type="text/javascript" src="CSSMenuWriter/cssmw4/menu.js"></script>
<style type="text/css" media="all">
<!--
@import url("CSSMenuWriter/cssmw4/menu.css");
-->
</style>

followed by a link to a stylesheet for the language translation module then I've set the body to use the class .varText:

<body class="varText">

and then nested inside wrapper and content <div> tags I've got the DIV with the menu:

<div id="services">
<div id="svcsContent">
<div id="textResize">
<ul class="level-0" id="cssmw4">
<li class="parent link"><a href="#" class="link">Choose a Font Size</a>
<ul class="level-1">
<li class="link"><a href="#" onclick="CMXwriteCookie('fSize',11,3650); return false;" style="font-size:11px" class="link">Small &gt; A</a></li>
<li class="link"><a href="#" onclick="CMXwriteCookie('fSize',14,3650); return false;" style="font-size:14px" class="link">Medium &gt; A</a></li>
<li class="link"><a href="#" onclick="CMXwriteCookie('fSize',18,3650); return false;" style="font-size:18px" class="link">Large &gt; A</a></li>
<li class="link"><a href="#" onclick="CMXwriteCookie('fSize',20,3650); return false;" style="font-size:20px" class="link">Larger &gt; A</a></li>
</ul>
</li>
</ul>

<script type="text/javascript">if(window.attachEvent) { window.attachEvent("onload", function() { cssmw4.intializeMenu('cssmw4',{select_current: 0, orientation: 2}); }); } else if(window.addEventListener) { window.addEventListener("load", function() { cssmw4.intializeMenu('cssmw4',{select_current: 0, orientation: 2}); }, true); }</script>
</div>

If you want to set a time when I can show it to you in a Connect session, I'll be happy to schedule the time so we can look at it. I greatly appreciate your help!

enthusiastically,
Mark

Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

Sign in to reply to this post

markhaynes75235

Calling a Javascript function from a menu item

In a support incident we found that the include script:

<script type="text/javascript" src="CSSMenuWriter/cssmw/menu.js"></script>

is only used in older browsers and was causing a conflict with other JavaScripts. Deleting that line fixed the problem - Jason noted that IE6 browsers may have problems with the menus when that script is not included.

I also found that IE 8 was showing errors in the include file menu.php. The last few lines on that page are javascript that call methods or functions in the include mentioned above. I deleted those lines from my menu.php files and everything works fine in current browsers.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...