href="#" onclick="func(); return false;" and css class problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dangt85
    New Member
    • Dec 2008
    • 3

    href="#" onclick="func(); return false;" and css class problem

    Hello,
    I have the following page:

    ...
    Code:
    <style type="text/css">
    body {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 12px;
    }
    
    #form-tabs {
    	background-color: #7F8A81;
    }
    #form-tabs ul {
    	padding: 20px 0 3px 0;
    	margin-left: 0;
    	border-bottom: 1px solid #778;
    	list-style: none;
    	margin: 0;
    }
    #form-tabs ul li {
    	display: inline;
    }
    #form-tabs ul li a {
    	padding: 3px 10px;
    	margin-left: 5px;
    	margin-top: 10px;
    	border: 1px solid #CED2B6;
    	border-bottom: none;
    	background-color: #E8E9E2;
    	text-decoration: none;
    }
    #form-tabs ul li a:link, #form-tabs ul li a:visited { 
    	color: #474F49; 
    }
    #form-tabs ul li a:hover {
    	color: #E8E9E2;
    	background-color: #717A73;
    	border-color: #586159;
    }
    #form-tabs ul li.current a:link {
    	color: #474F49;
    	background-color: #FFFFFF;
    	border-color: #586159;
    }
    </style>
    <script src="js/jquery-1.2.6.min.js" language="javascript"></script>
    <script language="javascript">
    <!-- Begin
    function move_form_tab(index) {
    	$("#form-tabs ul li").removeClass("current");
    	$("#form-tabs ul li").eq(index).addClass("current");
    	$("#partial-forms div").css("display", "none");
    	switch(index) {
    		case 0:
    			$("#datos-personales").css("display", "block");
    			break;
    		case 1:
    			$("#datos-vivienda").css("display", "block");
    			break;
    		case 2:
    			$("#datos-laborales").css("display", "block");
    			break;
    		case 3:
    			$("#datos-financieros").css("display", "block");
    			break;
    		case 4:
    			$("#referencias-bancarias").css("display", "block");
    			break;
    		case 5:
    			$("#referencias-personales").css("display", "block");
    			break;
    		case 6:
    			$("#datos-conyugue").css("display", "block");
    			break;
    	}
    }
    // End -->
    </script>
    </head>
    <body>
    <div id="form-tabs">
      <ul>
        <li class="current"><a href="#" onclick="javascript:move_form_tab(0); return false;">Datos Personales</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(1); return false;">Datos de Vivienda</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(2); return false;">Datos Laborales</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(3); return false;">Datos Financieros</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(4); return false;">Referencias Bancarias</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(5); return false;">Referencias Personales</a></li>
        <li><a href="#" onclick="javascript:move_form_tab(6); return false;">Datos del C&oacute;nyugue</a></li>
      </ul>
    </div>
    <div id="partial-forms">
      <div id="datos-personales">datos-personales</div>
      <div id="datos-vivienda">datos-vivienda</div>
      <div id="datos-laborales">datos-laborales</div>
      <div id="datos-financieros">datos-financieros</div>
      <div id="referencias-bancarias">referencias-bancarias</div>
      <div id="referencias-personales">referencias-personales</div>
      <div id="datos-conyugue">datos-conyugue</div>
    ...

    The problem that I'm having is that the .current styles are not rendering well in browsers other than IE7.

    Any help will be very apreciated!
    Last edited by acoder; Dec 23 '08, 01:03 PM. Reason: Added [code] tags
  • phvfl
    Recognized Expert New Member
    • Aug 2007
    • 173

    #2
    Have you tried validating the page using the W3C validator? Validation errors can often cause pages to render differently where different browsers make different assumptions to correct for the errors. Another issue is that IEs non-conformance to web standards cause styles to look differently in IE to other browsers. Have you included a valid DOCTYPE to force IE into standards mode instead of quirks mode?

    Is the style change being applied and not looking correct or is the style change not being applied at all in any browser other than IE? Is the page visible anywhere that people can access to investigate further?

    Comment

    • dangt85
      New Member
      • Dec 2008
      • 3

      #3
      Thanks, I looked into the w3c validator and showed me that I had an error on the script tag atritues for the javascript. So it should be:

      <script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
      <script type="text/javascript">

      instead of:

      <script src="js/jquery-1.2.6.min.js" language="javas cript"></script>
      <script language="javas cript">

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Rather than just setting a:link, set all pseudo-classes or just a:
        Code:
        #form-tabs ul li.current a

        Comment

        • dangt85
          New Member
          • Dec 2008
          • 3

          #5
          Thanks... that solved the problem in Firefox.

          Other browsers (Safari, Opera and IE7) rendered the page well.

          Thanks again!

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You're welcome. Glad to help :)

            Comment

            Working...