Javascript/ Usercontrol Error

Hello, I have some webuser controls that I load onto an aspx page at runtime. Within these controls I allow the user to show and hide a div using a javascript function on the parent page and a little css. I have a straight html page with an example below which does not produce the "done with errors javascript error and the bottom of the page". In aspx pages it does.

In my parent page I have the javascript function. Within all the controls I have the toggle buttons and the div.

It works fine but I would like to get it working without the error...
<html xmlns="">
<head runat="server">
    <title>Untitled Page</title>
   <style type="text/css">
div#commentForm{  margin: 0px 20px 0px 20px;  display: none;color:black}
    <script language="javascript" type="text/javascript">
function toggleLayer( whichLayer )
var elem, vis;  
if( document.getElementById ) // this is the way the standards work    
elem = document.getElementById( whichLayer );  
else if( document.all ) // this is the way old msie versions work      
elem = document.all[whichLayer];  else if( document.layers ) // this is the way nn4 works    
elem = document.layers[whichLayer];  
vis =;  
// if the style.display value is blank we try to figure it out here  
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
vis.display = (vis.display==''||vis.display=='block')?'none':'block';}
    <form id="form1" runat="server">
    <a href="javascript:toggleLayer('commentForm');" title="Show Div">Show Div</a>
    <div id="commentForm">dfasdfasdfasdfasdfasdf<br /><br />
     <input type="reset" name="reset" value="Hide Div"onclick="javascript:toggleLayer('commentForm');" /></div>

Open in new window

Who is Participating?
sunithnairConnect With a Mentor Commented:
Alternately you can enable script debugging from IE->internetoptions->advanced tab->uncheck disable script debugging apply and reload the page. When is asks for debud press yes and see which line creates the problem and let us know
Can you click on the little exclamation mark next to which it shows done with errors and see what is the exact error. Please paste that here
gogetsomeAuthor Commented:
Thank you! It was some other script and not this one that was causing the error.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.