The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
It's only simple, but still... I was quite pleased with myself.
> What did it do?
As I said, it's very simple. Basically nothing more than string handling.
I sell stuff on eBay, eBid and QXL and have links in my listings to my auction Terms & Conditions, hosted on my own webspace.
Until now, they've all linked to the same document, but I'm going to make some subtle changes to the T&Cs between the sites, so I wanted to redirect to the correct version depending on which site the user was coming from.
So I looked up some guides to JS and had a go... and it worked!
I have 2 templates for my listings, one for UK-only auctions and one for international auctions. These linked to documents TandC_UK.htm and TandC_Global.htm respectively, irrespective of whether the user was coming from eBay, eBid or QXL.
I've replaced these documents with a page which calls my simple JS function and redirects to the correct T&Cs.
> Give us your code, schvinehund!
Okay, but don't laugh! There may be a better, more efficient way of doing it, but I'll find that out in time.
There are two copies of this script - one for UK auctions, one for international. As they are called from two different eBay templates, I've not yet figured out how (or even if) I can do it all in one.
Not sure how this will look with formatting and all that, but here goes...
[EDIT: Removed my domain name!]
-----
function ShowTandC() {
var sReferringSite = document.referrer.toLowerCase(); // Referring URL.
var sCurrentURL = location.href; // Current URL of selected T&Cs.
var nAnchorPos = sCurrentURL.lastIndexOf('#'); // Position of Named Anchor, if present.
if (nAnchorPos > -1) { // If Named Anchor is present, extract it...
var sAnchorName = sCurrentURL.substring(nAnchorPos);
}
else {
var sAnchorName = ''; // ...otherwise set to null.
}
if (sReferringSite.indexOf('ebay') > 0) { // Check if referrer was eBay.
var sNewPath = 'ebay';
}
else {
if (sReferringSite.indexOf('ebid') > 0) { // Check if referring site was eBid.
var sNewPath = 'ebid';
}
else {
if (sReferringSite.indexOf('qxl') > 0) { // Check if referring site was QXL.
var sNewPath = 'qxl';
}
else { // Can't detect referring site, display options.
var sNewPath = 'common';
}
}
}
var sNewURL = 'http://mysite.co.uk/' + sNewPath + '/popups/TandC_Global.htm' + sAnchorName;
location.href = sNewURL;
}
It is pleasing to get your first JavaScript going and working properly. HTML doesn't give quite so much of a buzz because it's stupidly simple, but JS is quite fussy, so good for you!
What did it do? Give us your code, schvinehund!
Have a cookiee.
It's only simple, but still... I was quite pleased with myself.