View Full Version : How are parameters passsed to HTML pages?
LastActionHero
July 4th, 2001, 07:06
How is it done?
lucifer
July 4th, 2001, 08:35
quick answer - it isn't :p
you need to use CGI (eg Perl), PHP, JSP, ASP, servlets etc
I'd recommend PHP it's the easiest IMO :)
LastActionHero
July 4th, 2001, 09:23
but i have seen webpages where it says somedomain/page.html?something
and how is this done?
http://in.yahoo.com/homemap/?http://edit.india.yahoo.com/config/mail?.intl=in
lucifer
July 4th, 2001, 10:07
probably some url rewriting going on but it won't be a html page as they can't do jack ----
LastActionHero
July 4th, 2001, 10:57
and how is that yahoo thing done a question mark after the back slash?
icanttype
July 4th, 2001, 18:09
Anything after ? is picked up as a QUERY_STRING variable. http://in.yahoo.com/homemap/ has an index file, index.cgi or something that gets called. For .html, I guess you can pick it up with JavaScript and by looking at the document url (if QUERY_STRING isn't available).
lucifer
July 4th, 2001, 18:58
Originally posted by icanttype
Anything after ? is picked up as a QUERY_STRING variable. http://in.yahoo.com/homemap/ has an index file, index.cgi or something that gets called. For .html, I guess you can pick it up with JavaScript and by looking at the document url (if QUERY_STRING isn't available). good point :o
LastActionHero
July 5th, 2001, 07:25
Originally posted by icanttype
Anything after ? is picked up as a QUERY_STRING variable. http://in.yahoo.com/homemap/ has an index file, index.cgi or something that gets called. For .html, I guess you can pick it up with JavaScript and by looking at the document url (if QUERY_STRING isn't available).
Thank you. :) Can you post a code snippet here to show us how it works?
lucifer
July 5th, 2001, 09:18
var url=window.location.href;
gets the full url then do what you like with it
LastActionHero
July 5th, 2001, 09:56
Thank you Lucifer. I'm guessing this will work in al browsers?
icanttype
July 5th, 2001, 12:06
Here's a bouncing sample... Seems to work on both IE5.5 and NN4.7 at least.
<script language="javascript">
url = window.location + "";
if (((i = url.indexOf("?")) >= 0) && ((query_string = url.substring(i + 1)) != "")) {
alert("Bouncing you to " + query_string);
window.location = query_string;
}
</script>
In PHP:
<? header("Location: $QUERY_STRING"); ?>
Koolguy
July 6th, 2001, 01:32
You can see the dif. in complexity, if you have access to PHP its far the best way.
You can also print out text using php
ie.
http://www.somesite.ext/?var=this is a test
<?echo('$var');?>
lucifer
July 6th, 2001, 04:13
surely
<?=$var?>
gyrbo
July 6th, 2001, 08:05
Bad PHP:
<? header("Location: $QUERY_STRING"); ?> (makes the browser go to $Query-string)
<?echo('$var');?> (Will print $var instead of the value of $var, should be <?php echo($var);?> or <?php echo $var; ?>)
RedHat
July 10th, 2001, 12:56
it's perfect possible in Javascript ... and way more easy !
And you don't need PHP support or anything ...
The code is very easy ...
var Param = location.search.substr(1);
Just look at http://users.belgacom.net/gc230251/test.html
and http://users.belgacom.net/gc230251/test.html?blablabla
You can split it with anyting (in the example with a "+" sign)
bv http://www.url.com/bla.html?para1+para2+para3
Parameter = location.search.substr(1).split("+");
document.write('The first Param was' + Parameter[0]);
document.write('The second Param was' + Parameter[1]);
....
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.