Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: Want to make a image changer. Please help. - September 10, 1998 at 09:42:11

You are here: irt.org | BBS | Re: Want to make a image changer. Please help. [This BBS is closed]

Posted by Jason Nugent on September 10, 1998 at 09:42:11:

In Reply to: Re: Want to make a image changer. Please help. posted by Auke on September 10, 1998 at 08:46:59:

: : Sure.. not difficult.. Post what you have so far and I'll take a look at it. A hint - read my Perl/CGI articles to get you started.

: : Jason

: Sorry, but i don't have anything so far. I want to do it in javascript, but i don't know how to read the url (www...com/index.htm?=blabla)

: Auke

Personally, I would do it with a CGI script. That way, you don't have to worry about browsers that don't support JavaScript or people who have JS turned off. But, if you wanna do it in JavaScript, you can.

var argsS = location.search.substring (1, location.search.length);
// argsS now contains a list of the arguments passed
// to the URL.

var args = argsS.split ('&'); // split it up on the ampersand.
// and store them in an array.

array now looks something like this:

name=Jason
file=myfile
etc....

Remember, the ampersand is used to separate arguments passed to a url.

for (var i = 0 ; i < args.length ; i ++ )
{
var frags = args[i].split ('='); // split it on the equals sign

var unEscapedFragment = unescape (frags[1]);
// frags[1] because frags[0] contains the optional name
// of the fragment in a name=value pair.
}

and you can then use unEscapedFragment anywhere you want in your page. I unescape it because certain characters are not allowed in a URL (the tilde, for instance, or spaces). You must hexadecimally convert these back to there 'real' values.
One other thing - this stuff needs JavaScript1.1 to work, so you are going alienate older browsers (like Netscape 2.0) which do not support it. This also means that you have to specify a language of JavaScript1.1 in your SCRIPT tags if you want older browsers to ignore it and not cause errors.

Jason
Follow-ups:

You are here: irt.org | BBS | Re: Want to make a image changer. Please help. [This BBS is closed]

©2018 Martin Webb