GetDotted Domains

Viewing Thread:
"I wrote my first ever JavaScript last night"

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.

Sat 24/09/05 at 15:52
"High polygon count"
Posts: 15,624
And it worked first time.

It's only simple, but still... I was quite pleased with myself.
Sat 24/09/05 at 16:41
Regular
"Pouch Ape"
Posts: 14,499
Ah, cool. Good work!
Sat 24/09/05 at 16:36
"High polygon count"
Posts: 15,624
monkey_man wrote:
> 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;
}
Sat 24/09/05 at 16:10
Regular
"tinycurve.gif"
Posts: 5,857
Well done!

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!
Sat 24/09/05 at 16:05
Regular
"Pouch Ape"
Posts: 14,499
A Wookiee Cookiee?

What did it do? Give us your code, schvinehund!
Sat 24/09/05 at 15:56
"High polygon count"
Posts: 15,624
Why thank you, sir.

Have a cookiee.
Sat 24/09/05 at 15:53
Regular
"Twenty quid."
Posts: 11,452
Well done.
Sat 24/09/05 at 15:52
"High polygon count"
Posts: 15,624
And it worked first time.

It's only simple, but still... I was quite pleased with myself.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thank you very much for your help!
Top service for free - excellent - thank you very much for your help.
Wonderful...
... and so easy-to-use even for a technophobe like me. I had my website up in a couple of hours. Thank you.
Vivien

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.