Click to See Complete Forum and Search --> : how do they do that?


kdfsa
05-21-2003, 02:54 PM
look at the website www.flashjester.com/index.html
when you select a link, for example "about" you are directed to a page with the address of www.flashjester.com/?section=about
all the links are like this. how do they do it? do they have one long web page, and are only displaying parts of it based on the section selected? Are they using html, cgi, etc.?

Vladdy
05-21-2003, 02:58 PM
Before getting into discussion on HOW, I'd like to know WHY would you want to do something like that...

David Harrison
05-21-2003, 03:02 PM
It's done using javascript, at least that's how I do it oon my website.
If in the case of my website there's this in the address bar:
.../main.html?joketype=clean
Then there is a scirpt inside everything.js that would find joketype and find clean and create a new variable called joketype with the value clean.

Then there is another script elsewhere similar to this:
if(joketype=="clean"){document.write("Clean Jokes");}
else{document.write("Dirty Jokes");}

I hope that this has answered your question.

AdamGundry
05-21-2003, 03:06 PM
Looks like CGI on the site you mentioned - a single CGI program probably reads the URL and produces the correct document based on it. It's not a good thing to do with Javascript because your page then can't be used if JS is disabled (approx. 10% of users).

Adam

kdfsa
05-21-2003, 03:40 PM
this was the first time that i really noticed what was happening in the address line. it was something new to me, so i was interested. i don't know if it's better or not, that's kind of what i was wanting to get from here, your thoughts. does it make things faster, or is there really no benefit at all? if it is, then is this a cgi script that reads selected sections from a html file or does it select an individual file(txt) and turn it into html?

David Harrison
05-21-2003, 04:20 PM
On my website I have two sections, clean jokes and dirty jokes. If when the user makes a choice I put it in the address bar I can save on the number of pages I use, because most of the content on each page is the same I can simply change bits of the content depending on the choice they have made. Also some of the pages are exactly the same but the problem is if they link to one of those and I don't "store" their choice and then from that page they link back to the jokes page I won't know which type of jokes they want to see.

AdamGundry
05-22-2003, 03:07 AM
I'd say there is not usually any benefit from that kind of CGI, unless you have a really large website which needs to be put together dynamically. If I was doing something like this in PHP, I'd probably use something like this:

<?php
// Set variable $page to URL requested
$page = $HTTP_GET_VARS['page'];

// Check page is valid (security)
if (($page != 'page1.html') and ($page != 'page2'html')){
die('Invalid page requested.');
}

// Include pages
require 'template_before.html';
require $page;
require 'template_after.html';
?>


This should give you an idea of the layout of such a script.

Adam