Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event Handler - Payment

Status
Not open for further replies.

steboy01

Technical User
Jun 16, 2003
6
0
0
GB
I have been working recently on an ecommerce site which uses a legacy evernt handler script at the checkout stage.

I have it working fine in IE but it does nothing in Firefox - think it was written in Netscape days, hopefully its something simple.

This is the event handler .js file, which is called from the payment.php file - im hoping a simple change can be made to this js file - can anyone help:

var isNav = (navigator.appName.indexOf("Netscape") !=-1);
var isIE = (navigator.appName.indexOf("Microsoft") !=-1);

function addhandlers(o)
{
o.onabort = handler;
o.onblur = handler;
o.onchange = handler;
o.onclick = handler;
o.ondblclick = handler;
o.onerror = handler;
o.onfocus = handler;
o.onkeydown = handler;
o.onkeypress = handler;
o.onkeyup = handler;
o.onmousedown = handler;
o.onmouseout = handler;
o.onmouseover = handler;
o.onmouseup = handler;
o.onmove = handler;
o.onreset = handler;
o.onresize = handler;
o.onselect = handler;
o.onsubmit = handler;
o.onunload = handler;

//FIRST, TELL THE BROWSERS TO REACT TO THE EVENT
if( document.captureEvents )
{
//non IE
if( Event.KEYPRESS )
{
//NS 4, NS 6+, Mozilla 0.9+
document.captureEvents( Event.KEYPRESS );
}
}

}

addhandlers(window);
addhandlers(document);

for (var d = 0; d < document.links.length; d++)
addhandlers(document.links[d]);

for (var d = 0; d < document.images.length; d++)
addhandlers(document.images[d]);

for (var d = 0; d < document.forms.length; d++)
{
addhandlers(document.forms[d]);

for (var e = 0; e < document.forms[d].elements.length; e++)
addhandlers(document.forms[d].elements[e]);
}
 
Perhaps because "handler" is not defined anywhere?

Fix that, and if that doesn't help, try removing these lines:

Code:
//FIRST, TELL THE BROWSERS TO REACT TO THE EVENT
if( document.captureEvents )
{
  //non IE
  if( Event.KEYPRESS )
  {
    //NS 4, NS 6+, Mozilla 0.9+
    document.captureEvents( Event.KEYPRESS );
  }
}

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for the reply Dan.

handler is defined in the php file within <script></script> tags before this js file is referenced. The code is:

function handler(e)
{
var strItem;

if (isNav)
{
}
else if (isIE)
{
e = window.event;

switch (e.type)
{

case '.. TODO ..':

switch(e.srcElement.name)
{
case '.. TODO ..':
........ TODO ........
break;
}
break;

default:
break;
}
}
e.cancelBubble = true;
}

I tried removing those lines you mentioned - it still seems to work in Internet Explorer without them, but no joy in Firefox
 
Thanks Dan

Any pointers on what i need to go there
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top