Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help! IE / Mozilla compatibility problem...

    This is some ASP code with some simple DHTML.
    It's supposed to create a table grid of pixels that change color as the mouse goes over them. It works fine in Mozilla buy not in IE. Someone please help!!!

    Code:
    <html>
    <head>
      <script language="javascript">
      
      function paint(td) {
        td.style.backgroundColor = 'black'; 
        }
        
      </script>
      <style>
      
    table {
        border-spacing: 0;
    	border-style: solid;
    	border-width: 1px;
    	border-color: black;
    	border-collapse:collapse;
    	padding: 0;
    }
    
    td {
    	border-style: none;
    	border-width: 0px;
    	padding: 0;
    }
    
      </style>
    </head>
    <body>
    <table>
    
    <%
    For y = 1 to 32
        response.write "<tr>"
        For x = 1 to 32
            response.write "<td height=2px width=2px name='td_" & x & "_" & y & "' " 
            response.write " style='background-color: white;' onmouseover='javascript: paint(this);'>"
        next
    next 
    
    %>
    </table>
    </html>

  • #2
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Let me help you clean this up a bit, then we can discuss changes.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    	<head>
    	  <script type="text/javascript">
    		function paint(td) {
    			td.style.backgroundColor = 'black'; 
    		}
    	  </script>
    	  <style type='text/css'>
    		table {
    		    border-spacing: 0;
    			border-style: solid;
    			border-width: 1px;
    			border-color: black;
    			border-collapse:collapse;
    			padding: 0;
    		}
    
    		td {
    			border-style: none;
    			border-width: 0px;
    			padding: 0;
    			height: 2px;
    			width: 2px;
    			background-color: white;
    		}
    	  </style>
    	</head>
    	<body>
    		<table>
    		<%
    		For y = 1 to 32
    		    response.write "<tr>"
    		    For x = 1 to 32
    		        response.write "<td name='td_" & x & "_" & y & "' " 
    		        response.write " onmouseover='paint(this);'>"
    		    next
    		next 
    		%>
    		</table>
    	</body>
    </html>
    I tested this in IE6.0 and it works correctly. You really should have a <tbody> though. Let me know how it goes for you.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the suggested changes make the code work fine on both IE6 and mozilla.

    thanks so much!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •