Patti Louise Ruby's Cool Javascript
Below you'll find the javascript code included in Chapter 6 of eBay Listings That Sell For Dummies.
Thanks for reading, and be sure to let us know if you have any problems with the scripts you find on this page.
To use one of the scripts, simply highlight the code, copy it from this page, and paste it in the appropriate section of
your listing description.
Disabling right click functions
<script language=”JavaScript”>
<!--
var message="Sorry,
that function is disabled.<br><br>Contents & Graphics Copyright 2005 Marsha Collier - this Art Work is NOT
Public Domain, and should NOT be taken from this site.";
///////////////////////////////////
function clickIE4(){
if
(event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if
(e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else
if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new
Function("alert(message);return false")
// -->
</script>
<script language="JavaScript1.2">
function
disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new
Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>
You should customize the message that appears by replacing the following with your
own text; after all, Marsha's message isn't in the public domain, either. (Friendly reminder.)
Sorry, that function is disabled.<br><br>Contents & Graphics Copyright 2005 Marsha Collier - this Art
Work is NOT Public Domain, and should NOT be taken from this site.
Displaying a Countdown Message
<script language=”JavaScript”>
//simple countdown script
var
leadupdays=" the end of our Clearance Sale! Don't wait -- make your purchase today!"
var ontheday="Final Clearance Sale
Day!"
var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countdown(yy,mm,dd){
var today=new Date()
var thisyear=today.getYear()
if
(thisyear < 1000)
thisyear+=1900
var thismonth=today.getMonth()
var thisday=today.getDate()
var todaystring=months[thismonth]+"
"+thisday+", "+thisyear
var targetstring=months[mm-1]+" "+dd+", "+yy
var difference=(Math.round((Date.parse(targetstring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if
(difference==0)
document.write(ontheday)
else if (difference>0)
document.write("Only "+difference+" days left
until "+leadupdays)
}
//target date formatted (yyyy,mm,dd)
countdown(2006,01,31)
</script>
Don't forget to make the changes to customize the script for your listing by following the directions in Chapter 6!