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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript IE compatibility problem

    Might anyone know WHY this script works in Firebird/Opera but does not work in IE based browsers...?

    If you need an explination, it's for changing the colors of table rows when moused over..based on two CSS classes (over and norm..) which change the look of the row. Basically, what doesn't work is the click function..the over works perfect. I think it might have something to do with the array.

    Code:
    var marked = new Array();
    
    function over(obj, state) {
    	if ( state == 'on' && marked[obj] != true ) {
    		document.getElementById(obj).className = 'over';
    	} else if ( marked[obj] != true ) {
    		document.getElementById(obj).className = 'norm';
    	}
    }
    
    function click(obj) {
    	if ( marked[obj] != true ) {
    		marked[obj] = true;
    		document.getElementById(obj).className = 'over';
    	} else {
    		marked[obj] = false;
    		document.getElementById(obj).className = 'norm';
    	}
    }
    Here is an example of how it could be implemented:
    Code:
    <tr class="norm" id="4" onMouseOver="over('4', 'on')" onMouseOut="over('4','off')" onclick="click('4')">

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In Moz you can do simple CSS, for IE here is my fix:
    http://www.vladdy.net/Demos/IEPseudoClassesFix.html
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I understand that. Thank you for the alternative..

    The mouseover isn't the problem. I want the row to stay hilighted when it's clicked...via storage in an array as I am doing. Your option still gives me no way to accomplish this in Javascript in IE browsers.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <tr onclick="highlight(this);">
    Code:
    function highlight(row)
      { //assuming that all rows are children of the same element (tbody)
        if(row.parentNode.highlightedRow)  row.parentNode.highlightedRow.className = '';
        row.className = 'highlight';
        row.parentNode.highlightedRow = row;
        return;
      }
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

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