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

    Exclamation onBlur event works in FireFox but not in IE6 on WindowsXP

    A simple script to test:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="javascript">
    <!--
    var numRows = 0;
    function regelToevoegen(){
    	var arrFields = new Array(					
    						new Array(true,	'veld1', false),
    						new Array(true,	'veld2', true),
    						new Array(true,	'veld3', false));
    	var theTable = document.getElementById('theTable');
    	var newPos   = theTable.rows.length-1;
    	var newRow   = theTable.insertRow(newPos);	
    	for(var i=0; i<arrFields.length; i++){
    		var newCell = newRow.insertCell(i);
    		if(arrFields[i][0]==true){
    		   var tempName = arrFields[i][1] + '[' + numRows + ']';
    		   var newEl   = document.createElement('input');
    		   newEl.setAttribute('type', 'text');
    		   newEl.setAttribute('name', tempName);
    		   newEl.setAttribute('id', tempName);
    		   newEl.setAttribute('size', 10);		
    		   if(arrFields[i][2]!=null && arrFields[i][2]==true){		   		
    				newEl.setAttribute("onBlur", "alert('onBlur event!')");
    		   }		
    		   newCell.appendChild(newEl);
    		}
    	} 
    	numRows++;  
    }
    //-->
    </script>
    <style media="all">
    td{	
    	text-align: center;
    }
    td, th{
    	font-family:Verdana, Arial, Helvetica, sans-serif;
    	font-size: 10px;	
    }
    </style>
    </head>
    
    <body>
    <form action="<? print $_SERVER['PHP_SELF']; ?>" method="post" name="formTest" id="formTest">
      <table id="theTable" width="500" border="0" cellspacing="1" cellpadding="5">
        <tr>
          <th width="30%">kolom 1</th>
          <th width="30%">kolom 2</th>
          <th width="30%">kolom 3</th>
        </tr>
        <tr>
          <td colspan="3" align="center"><a href="javascript:void(0);" onClick="javascript:regelToevoegen();">rij toevoegen</a></td>
        </tr>
      </table>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    <pre>
    <? print_r($_POST); ?>
    </pre>
    </body>
    </html>
    When you add a row, 3 tablecells are generated.
    The second cell should have an onBlur-event.

    It works well in FireFox, but not in IE6 on Windows XP.

    Does anyone know how I can make this work?

    Patrick
    Last edited by SpartaRotterdam; 06-04-2004 at 11:43 AM. Reason: rewrite code

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change this:
    Code:
    newEl.setAttribute("onBlur", "alert('onBlur event!')");
    To this:
    Code:
    newEl.onblur = function() { alert('onBlur event!'); }

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thisn worked eventually:

    Code:
    newEl.onblur = new Function("alert('hello')");

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why use constructor notation? That's less efficent than the annoymous function notation I provided above.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    fredmv is right. Function constructor is similar to eval in behavior.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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