Dear Dr. Website®: How do I insert a command in a hyperlink that brings back the previously visited Web page? In other words, a command with the same function as the browser's Back button?
To do this, you can use the history object:
<A HREF="javascript:history.go(-1)">move back</A>
You can play with the number contained in the history.go function to make the returned page more distant.
Dear Dr. Website®: I am attempting to hide a form in the head of an HTML page so that a user does not notice it. I'm also attempting to submit that form upon load of that page. I am not using a function, but am just having the script load with the rest of the page. There is not a problem with this in Netscape, but in IE I receive the error "Document.formname is not an object." I'm using the most current of browsers, as that will be what my users will use. Can you help?
Although we question your reason for doing this, the correct method is to use an onLoad event to execute a function that submits the form:
function loadit() {
document.myform.submit();
}
<body onLoad="loadit()">
This will work for both IE and Netscape.
Dear Dr. Website®: What's a cgi-bin? What is it for?
CGI stands for Common Gateway Interface, a standard for how Web servers interact with external programs. The cgi-bin is the directory where CGI scripts are kept.
CGI scripts are executable files--or rather, files the server uses to accomplish special tasks.
This might include handling the data from a form, determining the user's Web browser and using that information to deliver the correct Web page, or writing the data from a site's guestbook to a file so the next visitor can read it. CGI scripts can be written in Perl, C, or many other languages, or they may simply be Unix shell scripts.
When a Web browser requests a CGI script, one instance of the script is spawned by the Web server in order to fulfill the request. If another user's browser makes the same request a second later, a new instance of the CGI script will be spawned. At times this can be tedious for the server, and response time can be slow. But even so, CGI scripts are very handy, and most large Web sites use them for one reason or another.
Dear Dr. Website®: I've created an order form. Now, how do I set it up so it actually works? That is, when users hit Submit, how do I receive the data? Do I send it to a separate data file, and if so, do I publish that data file to the Web?
First, you need to decide whether or not you want the data stored on the system. If you don't need that to happen, you could simply use a mailto: as the action for the form. Then the data would be sent to you in an e-mail. This is not popular, as it forces the visitor's e-mail client to open. Not very efficient, and not very state-of-the-art.
A better solution is to use a CGI script, if you have access to the cgi-bin on your host's Web server. In this case, you'd not only get an
e-mail with the data, but you could also store the data on the system. Although there are many commercial CGI applications that do the job, many free scripts work just fine. One site you'll want to visit is ScriptSearch.com; it has a whole section on form-handling Perl scripts.
Once you decide on a particular script, you'll have to edit it for your server's specific configuration. If you don't have direct access to the server, you may have to pay for your ISP to configure the script for you. On that note, you may also want to check with your host or ISP, as they sometimes have specific scripts for customers to use. And if you want an actual secure server script (using SSL), that's another ball of wax altogether...
Dear Dr. Website®: I have created a Web site that uses Java. I'm looking for some kind of program or script that identifies the user's browser and, if that user's browser doesn't support Java, reroutes the user to a non-Java version. Please tell me if you know of anything like this.
The first question you should ask is: How many browsers out there support scripting--such as JavaScript, JScript, or VBScript--but not Java? Very few, we'd say.
As such, here's what you do: Make a list of which browsers and versions of browsers support Java. Use that list in a CGI script that reads visitors' browser headers; the script should compare each browser type with the list, and if the browser is not on the list, the script can send the user to a non-Java page. Of course, you could always enclose non-Java code within the Java applet code in your page, and then only those without a Java-enabled browser (or those with Java turned off) would see the non-Java code--all others would see the applet.