Javascript chrome issues

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Javascript chrome issues

Post by kingconnections »

I am trying to do some simple things with javascript. The actions work in IE but not in chrome or firefox and I am not sure why.

Code: Select all

 
 
<script type="text/javascript">
 
/////////////////////////////////
// search functions
/////////////////////////////////
 
function doClear(filter) 
{ filter.value="";}
 
 
function checkEnter(){
    /*if enter is pressed in a filter field, update the search box*/
    if (event.keyCode == 13){
        doSearch(filter);
            }
}
 function doSearch(filter) 
{ //alert(filter.value);
    url="http://2k3-nonprod01/cv/search.php?search_string=" + filter.value; 
    //alert(url);
    window.open(url,"_self");
 }
 
</script>
<input type="text" id="search_box" name="filter" value="Search for a Server" onFocus=doClear(this) onKeyDown=checkEnter()></input>
<img src="images/search.png" id="search_image"  onclick=doSearch(filter)></img>
 
 
Basically just clearing the search box.
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Re: Javascript chrome issues

Post by kingconnections »

OK - apparently the window.event is an IE only action. I found a work around that appears to work for both.

Code: Select all

 
 
<script type="text/javascript" language="JavaScript">
 
function checkCR(e) {
 
var Key=e.keyCode? e.keyCode : e.charCode;
 
       if( Key == 13){
 
        alert("You press enter button"); 
        }
 
}
 
</script>
 
 
<input type="text" name="txtEnterPageNo" id="txtEnterPageNo" size="3" onkeypress="checkCR(event);">
 
 
Post Reply