• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javascript in Netscape4.7  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing some problem with Netscape4.7.The javascript code that works fine in IE?(internet explorer) doesn't work in Netscape.What are the requisite changes to be made in the code so that javascript validation works fine in Netscape4.7.
It gives Javascript error.

The code is as follows
<SCRIPT language=JavaScript><!--/******************************************The next section automatically adds '(', ')',and '-' characters to phone number fieldsas the user types (so the user only needsto type the 10 numbers).******************************************/");
function phoneDisplay(i, delKey)
{ if(delKey!=8 && delKey!=46 && delKey!=9 && delKey!=16 && !(delKey>36 && delKey<41))
//if the delete, backspace, tab, shift, are not the keys that caused the keyup event.");
var fieldLen = i.value.length;var areaCode = ""; var exchange ="";
var lastFour = "";var currVal = i.value;var firstParens = 1;
var firstParens = parseInt(i.value.lastIndexOf("(")) + parseInt(1);
var secondParens = 5;var secondParens = parseInt(i.value.lastIndexOf(")")) + parseInt(1);
if(firstParens < 1){ firstParens=1; }
if(secondParens < 1){ secondParens=5; }
if(fieldLen==1 && currVal!="(")
{ areaCode = i.value; }
{areaCode = i.value.substring(firstParens,4);}
if(fieldLen>4){exchange = i.value.substring(secondParens,8);}
if(fieldLen>7){lastFour = i.value.substring(9,13);}
//alert("x" + lastFour + "y");");
if(fieldLen<4){i.value = "(" + areaCode ; i.focus();}
{i.value = "(" + areaCode + ")" + exchange;i.focus();}
elseif(fieldLen<13){i.value = "(" + areaCode + ")" + exchange + "-" + lastFour; i.focus(); } } }
//end if delete key=8,46}");
function phoneBlur(i){
var formName= document.forms[0].name;
function phoneFocus(i)
{ var formName = document.forms[0].name;
var formLength =document.forms[0].length;
{i.value="("; i.focus(); i.select(); }
else { i.select(); }}
function testKey(e){
<SCRIPT event=onfocus for=telephonenumber1>phoneFocus(this);</SCRIPT>
<SCRIPT event=onfocus for=telephonenumber2>phoneFocus(this);</SCRIPT>
<SCRIPT event=onfocus for=faxnumber>phoneFocus(this);</SCRIPT>
<SCRIPT event=onblur for=telephonenumber1>phoneBlur(this);</SCRIPT>
<SCRIPT event=onblur for=telephonenumber2>phoneBlur(this);</SCRIPT>
<SCRIPT event=onblur for=faxnumber> phoneBlur(this);</SCRIPT>

<SCRIPT event=onkeyup for=telephonenumber1>phoneDisplay(this, window.event.keyCode);</SCRIPT>
<SCRIPT event=onkeyup for=telephonenumber2>phoneDisplay(this, window.event.keyCode);</SCRIPT>
<SCRIPT event=onkeyup for=faxnumber>phoneDisplay(this, window.event.keyCode);</SCRIPT>
<form name="NC3" method="get" action="../../CD532_CustomerLocationWizard" onSubmit="return testdata(this)">
<table align=center class="CyDwWizDefaultColour">

<td>Telephone Number 1<font color=\"#FF0000\">*</font></td>
<input type="text" name="telephonenumber1" DATASRC="#osia" DATAFLD="telephonenumber1" maxlength="13" onkeypress="testKey(event)">

bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For netscape, in order to capture events you have to trap them differently than you do in IE. So with IE you can just say document.onkeypress to get your event, for Netscape you have to write it differently.
So for Netscape it looks like this:
document.captureEvents(Event.KEYPRESS) and that captures your keypresses. And then you direct it to the onKeyPress event with:
I am not sure if keypress is an event in Netscape so you may have to double check that and change it to onkeyup or something like that.
Check out this link for more info on how to capture events in Netscape and IE:
Hope that gives you a start.
santosh salvi
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to make code compatible for both ie & netscape, but netscape 4.7 has many difficulties.a few are listed
Block hiding / Display:none, property not working, visible not working(Visibility='Hidden' or Visibility='visible' not working for TR , TD, DIV, TABLE.
inserting a frame through insertAdjacentHTML document.body.insertAdjacentHTML("beforeEnd","<IFRAME name='IOFrame' width=0 height=0></IFRAME>");
this works in ie and nn6.0 but not in 4.7!!
to create and submit hidden forms does not work tried using layers but still does not work. Can we not have dynamic pages in netscape?
Will someone pls share a idea on how to do it.
Thanks in advance
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!