www.webdeveloper.com
Results 1 to 5 of 5

Thread: IE onclick problem, works with FF

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    IE onclick problem, works with FF

    Hi, I have a few javascript functions which work perfectly well in Firefox, but do nothing in IE.

    Since they DO work in FF, there must be some very small tweaking that needs to be done to make this understandable for IE..

    I didnt include the CSS

    Javascript:
    Code:
    <script type="text/javascript"> 
    <!--
    var state = 'hidden';
     
    function showhide(layer_ref) {
        if (state == 'visible') {
        state = 'hidden';
        }
        else {
        state = 'visible';
        }
        if (document.all) {
        eval( "document.all." + layer_ref + ".style.visibility = state");
        }
        if (document.layers) {
        document.layers[layer_ref].visibility = state;
        }
        if (document.getElementById && !document.all) {
        maxwell_smart = document.getElementById(layer_ref);
        maxwell_smart.style.visibility = state;
        }
    }
    function hide(layer_ref) {
        if (state == 'visible') {
        state = 'hidden';
        }
    	if (document.all) {
        eval( "document.all." + layer_ref + ".style.visibility = state");
        }
        if (document.layers) {
        document.layers[layer_ref].visibility = state;
        }
        if (document.getElementById && !document.all) {
        maxwell_smart = document.getElementById(layer_ref);
        maxwell_smart.style.visibility = state;
        }
    }
     
    //-->
    </script>
    and here is the HTML

    HTML Code:
    <div class="ivo2">
    
    	<div class="ivo2-nav">
    	<a href="#" onclick="showhide('ivo2-block1');document.getElementById('ivo2-nav-link1').style.background='#FFA766';document.getElementById('ivo2-nav-link2').style.background='#FFD69D';hide('ivo2-block2');return false"  id="ivo2-nav-link1">Most Active</a>
    	</div>
    	
    	<div class="ivo2-nav">
    	<a href="#" onclick="showhide('ivo2-block2');document.getElementById('ivo2-nav-link1').style.background='#FFD69D';document.getElementById('ivo2-nav-link2').style.background='#FFA766';hide('ivo2-block1');return false"  id="ivo2-nav-link2">New</a>
    	</div>
        	
    	<div id="ivo2-block1">foo</div>
        	<div id="ivo2-block2">bar</div>
    
    </div>
    Has anybody else come across a problem like this?

  2. #2
    Join Date
    Sep 2009
    Posts
    5
    It gives a Syntax error for the following line:

    Code:
    eval( "document.all." + layer_ref + ".style.visibility = state");

  3. #3
    Join Date
    Sep 2009
    Posts
    5
    Ok i removed this "eval" function and now the tabs work, there is no more error, but there still remains the hide function which doesn't seem to be working yet in IE

  4. #4
    Join Date
    Sep 2009
    Posts
    5
    anybody got any ideas?

  5. #5
    Join Date
    Sep 2009
    Posts
    5
    need to bump this thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles