Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:43

JavaScript is Crazy, anyway!


Poster: rcisney
Dated: Wednesday May 18 2005 - 22:39:27 BST

Hey, y'all,

I'm getting an error when I use these menus in a .NET application.
I build everything using a stringbuilder, and then it tells me I'm missing a closing parenthesis ")".... Can anyone see it? Below, I'll post the .NET code , followed by what it renders in the browser.....

Note: If I drop the rendered text into vss and look at *exactly* where the ie parser tells me the error is, it seems I'm missing the close paren from between the "#d" and "dd" in this line of the rendered code...

offcolor="#ddd";

***************************************************
.NET Code
***************************************************

protected override void Render(HtmlTextWriter output)
{
CMSSiteType cmsst=new CMSSiteType();
StringBuilder sb = new StringBuilder();


sb.Append("<script language=javascript src=/NR/rdonlyres/187872B0-547F-43D6-BB64-1FE123BEBCFC/0/milonic_src.js></script>");
sb.Append("<script language=javascript>");
sb.Append("if(ns4) _d.write(\"<script language=javascript src=/NR/rdonlyres/B788A010-81D1-46FB-98EB-B9105F9B3FAC/0/mmenuns4.js><\\/scr\"+\"ipt>\"); ");
sb.Append("else _d.write(\"<script language=javascript src=/NR/rdonlyres/A4F3C137-F7EC-4DFF-8506-154BBA25A449/0/mmenudom.js><\\/scr\"+\"ipt>\"); ");
sb.Append("</script>");


sb.Append("<script language=javascript>");

sb.Append("_scrollAmount=3;");
sb.Append("_scrollDelay=20;");
sb.Append("_menuCloseDelay=500;");
sb.Append("_menuOpenDelay=150;");
sb.Append("_subOffsetTop=5;");
sb.Append("_subOffsetLeft=-10;");

sb.Append("with(mainStyle=new mm_style()){");
sb.Append("onbgcolor=\"#666\";");
sb.Append("oncolor=\"#fff\";");
sb.Append("offbgcolor=\"#333\";");
sb.Append("offcolor=\"#ddd\";");
sb.Append("borderwidth=1;");
sb.Append("bordercolor='black';");
sb.Append("borderstyle='solid';");
sb.Append("separatorcolor='black';");
sb.Append("separatorsize=1;");
sb.Append("padding=3;");
sb.Append("fontsize='85%';");
sb.Append("fontstyle='normal';");
sb.Append("fontweight='bold';");
sb.Append("fontfamily='Tahoma,verdana, arial, helvetica, sans-serif';");
sb.Append("subimage=\"/NR/rdonlyres/6B0CAF65-EBFB-4D9F-8260-515FE17DFBD8/0/arrow.gif\";");
sb.Append("pagecolor='#fff';");
sb.Append("pagebgcolor='#777';");
sb.Append("}");

sb.Append("with(milonic=new menuname(\"Igateway\"");
sb.Append(")){");
sb.Append("style = mainStyle;");
sb.Append("top=169;");
if (WebAuthorContext.Current.Mode.ToString()!="AuthoringPreview" && WebAuthorContext.Current.Mode.ToString()!="TemplatePreview" && WebAuthorContext.Current.Mode.ToString()!="PresentationUnpublishedPreview" && (!cmsst.IsSiteReadOnly()))
{
sb.Append("left=245;");
}
else
{
sb.Append("left=60;");
}
sb.Append("alwaysvisible=1;");
sb.Append("orientation=\"horizontal\";");
sb.Append("aI(");
sb.Append("text=Sign&nbsp;up&nbsp;for&nbsp;Institutional&nbsp;GATEWAY&nbsp;today!;");
sb.Append("url=http://localhost/NR/exeres/4561C454-058A-45AC-9557-95B27A0346E1.htm?wbc_purpose=Basic&NRMODE=Unpublished&WBCMODE=PresentationUnpublished&guid=4561C454-058A-45AC-9557-95B27A0346E1;");
sb.Append("status=Link to Institutional Gateway Signup Page;");
sb.Append(");}");

***************************************************
END CODE
***************************************************

And now, what that code turns into (IE6)...



***************************************************
RENDERED BY BROWSER
***************************************************

<script language=javascript src=/NR/rdonlyres/187872B0-547F-43D6-BB64-1FE123BEBCFC/0/milonic_src.js></script>
<script language=javascript>

if(ns4)
_d.write("<script language=javascript src=/NR/rdonlyres/B788A010-81D1-46FB-98EB-B9105F9B3FAC/0/mmenuns4.js><\/scr"+"ipt>");
else
_d.write("<script language=javascript src=/NR/rdonlyres/A4F3C137-F7EC-4DFF-8506-154BBA25A449/0/mmenudom.js><\/scr"+"ipt>");
</script>

<script language=javascript>
_scrollAmount=3;
_scrollDelay=20;
_menuCloseDelay=500;
_menuOpenDelay=150;
_subOffsetTop=5;
_subOffsetLeft=-10;

with(mainStyle=new mm_style())
{
onbgcolor="#666";
oncolor="#fff";
offbgcolor="#333";
offcolor="#ddd";
borderwidth=1;
bordercolor='black';
borderstyle='solid';
separatorcolor='black';
separatorsize=1;
padding=3;
fontsize='85%';
fontstyle='normal';
fontweight='bold';
fontfamily='Tahoma,verdana, arial, helvetica, sans-serif';
subimage="/NR/rdonlyres/6B0CAF65-EBFB-4D9F-8260-515FE17DFBD8/0/arrow.gif";
pagecolor='#fff';
pagebgcolor='#777';
}

with(milonic=new menuname("Igateway"))
{
style = mainStyle;
top=169;
left=245;
alwaysvisible=1;
orientation="horizontal";
aI(text=Sign&nbsp;up&nbsp;for&nbsp;Institutional&nbsp;GATEWAY&nbsp;today!;url=http://localhost/NR/exeres/4561C454-058A-45AC-9557-95B27A0346E1.htm?wbc_purpose=Basic&NRMODE=Unpublished&WBCMODE=PresentationUnpublished&guid=4561C454-058A-45AC-9557-95B27A0346E1;status=Link to Institutional Gateway Signup Page;);
}

drawMenus();
</script>


***************************************************
END RENDERING
***************************************************


Poster: John
Dated: Wednesday May 18 2005 - 22:57:51 BST

Not right offhand. However, the aI statements need to be enclosed in "", like this...
Code:
aI("text=Sign&nbsp;up&nbsp;for&nbsp;Institutional&nbsp;GATEWAY&nbsp;today!;url=http://localhost/NR/exeres/4561C454-058A-45AC-9557-95B27A0346E1.htm?wbc_purpose=Basic&NRMODE=Unpublished&WBCMODE=PresentationUnpublished&guid=4561C454-058A-45AC-9557-95B27A0346E1;status=Link to Institutional Gateway Signup Page;");


The &nbsp; aren't needed in the text= - unless you have a specific reason for them.

Also, please use the code tags when posting code. Things can get lost otherwise.


Poster: kevin3442
Dated: Thursday May 19 2005 - 3:55:25 BST

Did it tell you that you were missing a ")" after an argument list? The cause would be the lack of quotes that John pointed out. Essentially, you're passing one long javascript string to the aI() function to build each menu item.

Good eye John.

Cheers,

Kevin

WooHoo! Eureka!


Poster: rcisney
Dated: Thursday May 19 2005 - 14:35:52 BST

Hats off to you guys. The Quotes fixed it!

Thanks!


Poster: John
Dated: Thursday May 19 2005 - 14:50:51 BST

kevin3442 wrote:
Good eye John.

Thanks, Pappy. :roll: Didn't think about that being the fix...