JavaScript is Crazy, anyway!

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
rcisney
Beginner
Beginner
Posts: 2
Joined: Wed May 18, 2005 10:20 pm

JavaScript is Crazy, anyway!

Post by rcisney »

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-058 ... B27A0346E1;");
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-058 ... tatus=Link to Institutional Gateway Signup Page;);
}

drawMenus();
</script>


***************************************************
END RENDERING
***************************************************
Thanks!

Rusty
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Not right offhand. However, the aI statements need to be enclosed in "", like this...

Code: Select all

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.
John
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

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
rcisney
Beginner
Beginner
Posts: 2
Joined: Wed May 18, 2005 10:20 pm

WooHoo! Eureka!

Post by rcisney »

Hats off to you guys. The Quotes fixed it!

Thanks!
Thanks!

Rusty
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

kevin3442 wrote:Good eye John.
Thanks, Pappy. :roll: Didn't think about that being the fix...
John
Post Reply