Below is a list of helpful Javascript functions that you can implement to help enhance
the security and overall usability of the payment process of your eCommerce website.
To prevent users from double clicking the "Process Payment" button on your website
and then being billed twice, the following Javascript code should be implemented.
This code only allows a button to be clicked once, if clicked again a dialog is
displayed and no further action is taken. This code is provided free of charge to
eWAY merchants.
<head>
<title>payment page</title>
<script language="JavaScript" type="text/javascript" >
//<!--
var submitcount = 0;
function checkFields(){
if (submitcount == 0) {
//sumbit form
submitcount ++;
return true;
}
else {
alert("Transaction is in progress.");
return false;
}
}
//-->
</script>
</head>
<form name="TXNDETAILS" ACTION="payment.asp" METHOD="post"
onSubmit="return checkFields()">
<input type="submit" value="Process Transaction using eWAY"
name="submit22"/>
</form>
Another useful piece of Javascript disables users using the right mouse button,
which adds another element of security to your web pages by restricting access to
the source code, properties, and other aspects.
Add this code between the <head> and </head> tags of your
web pages.
<script language="JavaScript" type="text/javascript" >
document.onmousedown = clickHandler;
function clickHandler(e) {
if (typeof(event) != 'undefined')
var button = event.button;
else if(typeof(e) != 'undefined')
var button = e.which -1;
else return false;
if(button != 2) return;
alert('No right clicking!');
window.focus()
return false;
}
</script>
This piece of JavaScript can also stop people from opening links on your web pages
in new browser windows. This is most useful if you use frames to add another layer
of security to your websites.
Add this code between the <head> and </head> tags of your
web pages.
<script language="JavaScript" type="text/javascript" >
function mouseDown(e) {
var shiftPressed=0;
if (parseInt(navigator.appVersion)>3)
{
if (navigator.appName=="Netscape")
shiftPressed=(e.modifiers-0>3);
else
shiftPressed=event.shiftKey;
if (shiftPressed)
{
alert ('Shift-click is disabled.')
return false;
}
}
return true;
}
document.onmousedown = mouseDown;
</script>
This script hides the URL's from appearing in the status bar, at the bottom of your
browser, when links are hovered over with the users mouse. This is most useful if
you use frames to add another layer of security to your websites.
Add this code between the <head> and </head> tags of your
web pages.
<script language="JavaScript" type="text/javascript" >
function hidestatus(){
window.status=''
return true
}
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
</script>