WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS
CSS Properties
Database
Design
Flash
HTML
HTML 4.01 Tags
JavaScript
.NET
PHP
Reference
Security
Site Management
Video
XML/RSS
WD Forums
 Client-Side
  Development

    HTML
    XML
    CSS
    Graphics
    JavaScript
    ASP
    Multimedia
    Web Video
    Accessibility
    Dreamweaver
    General
    Accessibility
    Dreamweaver
    Expression Web

    General

 Server-Side
  Development

    PHP
    Perl
    .NET
    Forum, Blog, Wiki & CMS
    SQL
    Java
    Others

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

 Etc.
    The Coffee Lounge
    Computer Issues
    Feedback




Q and A

Looking for the answer to that nagging Web development question? You've come to the right place.

HTML

Question: How can I prevent sensitive data from being viewable by another visitor when a user clicks the Back button of a browser?
Answer: Using a META tag in your HEAD tags,
you set the page to expire on a date that has already passed, and use the Pragma parameter to tell the browser not to cache the file.

<META HTTP-EQUIV= "expires"content = 
"Wednesday, 27-Dec-95 05:29:10 GMT"> <META HTTP-EQUIV="Pragma" CONTENT="no_cache">


Question:How would you write a routine (in JavaScript, if possible) to display a series of pages automatically one after another at a fixed time interval (i.e 10 seconds or so)?
Answer: There is no need for JavaScript in this instance. You can use META tags to do the trick:
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=nexturl.html">
and you vary the rate at which it loads the next page by replacing the CONTENT="0 to be CONTENT="10 or whatever you want. Be careful of the quote marks though; the syntax is a bit odd!


Question: I have a frameset with 3 frames and on one of the frames I want a single link to update the two other frames with new urls. How do I do it?
Answer: Using a little JavaScript (any browser that supports frames also supports JavaScript):

<SCRIPT LANGUAGE="JavaScript">
<!--//
function spreadit(){
top.upperright.location.href="upright.html";
top.lowerright.location.href="downright.html";
}
//-->
</SCRIPT>

where upperright and lowerright are the names of the frames. Call the function from a hyperlink:

<A HREF="javascript:spreadit()">update two frames</A>

Question: Are you isolating your potential audience if you use tables?
Answer: Now that even Lynx supports tables, virtually every browser will recongnize your tables, including AOL. Go ahead with your table use, it's a safe bet. If tables make your site more functional, there is no reason not to use them.


Question: If you don't open a new window for an external link, does this discourage the user from returning?
Answer: That's a matter of opinion...most people don't do this, but it can help remind a user in the midst of a heavy surfing session where s/he got started in the first place! It might not be supported by all browsers equally well, though. We don't do it ourselves, if that helps.


Question: How can you include a subject in a mailto tag?
Answer: Like this:
<A HREF="mailto:email@yours.com?subject=new email">

Question: How can you make the data from a form readable using a mailto action?
Answer: By including an ENCTYPE="text/plain" parameter in your form, like this:
<FORM ENCTYPE="text/plain" ACTION="mailto:you@yours.com"
METHOD="POST"> <INPUT TYPE=TEXT NAME="info"> <INPUT TYPE=SUBMIT> </FORM>

Question: How do I open a new browser window with an A HREF tag?
Answer: By using the TARGET parameter in the A HREF tag, like this:
<A HREF="newurl.html" TARGET="_new">new window</A>
where "_new" is not the name of any open browser window.


Question: How can I replace a framed page with another unframed page using a hyperlink?
Answer:You'd use "_top" as your target parameter within the A HREF tag:
<A HREF="yoururl.html" TARGET="_top">go to a no-frame version</A>
as "_top" causes the current page to be replaced by the new URL. Of course, you'll have to write a non-frames version of the page to be called by the tag.


Click here for more questions, answers, resources, and information about HTML.
Java

Question: What is the difference between an applet and an application?
Answer: A Java application is made up of a main() method declared as public static void that accepts a string array argument, along with any other classes that main() calls. It lives in the environment that the host OS provides.

A Java applet is made up of at least one public class that has to be subclassed from java.awt.Applet. The applet is confined to living in the user's Web browser, and the browser's security rules, (or Sun's appletviewer, which has fewer restrictions).


Question: What are the security limitations of an applet in a Web browser? Is there any way to get around them?
Answer: Java was developed with the intent to prevent applets from inspecting or changing files on the client file system, or from using network connections to circumvent file protections or people's expectations of privacy.

What this means for developers is that your applet will only be able to read to and write from a file on the server that the applet was served from. Using Sun's appletviewer, however, you can specify which files on your PC may or may not be read/written by an applet or application. This may be fine when you are developing applets for you or your companies use, but it won't do much for you if you are developing applets for the Internet.

The JDK 1.1 provides the ability to load and authenticate signed classes. This enables browsers to run trusted applets in a trusted environment, but as of yet most browsers do not support the JDK 1.1. For more information on security, check out Sun's Java Applet Security FAQ.


Click here for more questions, answers, resources, and information about Java.
Multimedia

Question: What is the syntax for embedding a Flash object into my HTML page?
Answer: It's pretty tricky and not quite intuitive, even by developer standards, so we'll point you right at Macromedia's own answer to this question.


Click here for more questions, answers, resources, and information about multimedia.
Site Management

Question: I am looking for some sort of correlation between the amount of hits per day and the required bandwidth. I know that this is also content deoendant, but I am looking for some sort of average. If I expect 1000 hits per day, what bandwidth would I need? 10,000, 100,000, a million? 10 million?
Answer: It is pretty much impossible to come up with a correlation between hits per day and bandwidth, as hits only indicate that something was requested from the HTTP server. They don't tell you if the hit was for a 25 KB HTML file, a 200 KB graphic, or a 10 MB zip file, so it's near impossible to find any way to correlate bandwidth usage.

Usage can be figured another way, however. According to BSDI, maker of the BSDI Unix operating system, "Users that utilize local services are limited by their modem or network communication speed. Reading mail, reading news, or sending mail/news are activities that use low-medium bandwidth in a bursty fashion. Even 100 users downloading files continually is only 28,800 bits/second/user x 1.7 (compression) x 100 users = 4,896,000 bps = 612,000 bytes/second, about half of one Ethernet. BSDI's system can, in fact, saturate multiple Ethernets to their maximum capacity.

Note, however, that if the 100 users above are accessing Internet facilities (e.g., by using WWW), then they can be bottlenecked severely by the network bandwidth. A 56K line is only 7,000 bytes (not bits) per second. That's just a tiny fraction of the downloading capacity listed above. A T-1 is faster: just under 200,000 bytes/second. Here is one way you can figure out your users' consumption rate to see how many bytes/second they require. I always figure about 10,000-30,000 bytes per WWW picture. If all the users are loading various WWW graphics simultaneously, they could end up waiting a while even on a T-1."


Click here for more questions, answers, resources, and information about Site Management.
Javascript

Question: How can I create a drop down list where a user can choose a page, and, after he has choosen from the drop down list, he is automatically taken to the page chosen from the list?
Answer: You can use this little code fragment to do just that. Simply replace the URLs in the array with your own site's URLs and do the same in the SELECT list in the order you placed them in the array. Here's the code in action:

And here's the code as it is written:

<SCRIPT LANGUAGE='JavaScript'>
<!--
function doArray() {
	var arylnth = doArray.arguments.length;
	for ( i = 0 ; i < arylnth ; i++ ) { this[i]=doArray.arguments[i] }
}

function newpage() {
var choose = eval(document.dropdown.site.selectedIndex);
if( (choose > 0) && (choose < 7) ) {
var section=new doArray( '', 'http://www.webdeveloper.com/index.html',
 'http://www.webdeveloper.com/library/',
 'http://www.webdeveloper.com/library/reference.html',
 'http://www.internetnews.com/wd-news/',
 'http://www.webdeveloper.com/reviews/',
 'http://www.webdeveloper.com/devforum/');

location=section[document.dropdown.site.selectedIndex];
      }
    }
//-->
</SCRIPT>

<FORM NAME="dropdown">
<SELECT NAME="site" onChange='newpage();' ALIGN="left">
<OPTION SELECTED>Select a Web Developer� Section
<OPTION>Main page
<OPTION>DoIt Library
<OPTION>Reference
<OPTION>Web Developer� News
<OPTION>Reviews
<OPTION>Developer's Forum
</SELECT>
</FORM>

Question: How can I close a browser window?
Answer: To close a window, use
<A HREF="javascript:window.close()">close it</A>
Note that later versions of Netscape ask the user with an alert if they wish to close the window.


Question: When try I use JavaScript to write to a document, I get an error message that tells me I need to use another semi-colon, that my syntax is wrong. It's the same syntax that I use directly in my code elsewhere, and it works fine. What's the deal??
Answer: Here is an example of the problem:

document.write('<FORM>');
document.write('<input type=button onClick="alert('Thank you
for your interest')";return true>');
document.write('</FORM>');
If you try using the code above, you will find that, although the code looks fine, no matter what you do, it will give you an error. The problem is the single inner quotes (although the same problem would extend to quotation marks as well). You need to include a backslash \ before the quote, thusly:

document.write('<FORM>');
document.write('<input type=button onClick="alert(\'Thank you
for your interest\')";return true>');
document.write('</FORM>');

This is not a well-published feature/bug of JavaScript, and can cause hours of frustration, so be careful with your quotes!


Question: How can I combine two JS events to be triggered by a single onLoad statement?
Answer: <BODY onLoad="window.status='Welcome to our home page.'; startclock()">


Question: How can I make the status bar of the browser show text that I choose when a user passes their mouse over a link? Answer: Using window.status, onMouseOver and onMouseOut, along with a little JavaScript function, we can easily do just that (try me)
<SCRIPT LANGUAGE="JavaScript">
function message(text){
window.status = text;
}
</SCRIPT>
<A HREF="test.html" onMouseOver="message('this is it');return true"
 onMouseOut="message('');return true"><B>(try me)</B></A>


Question: How do I load an image but not display it? Then when a user clicks on something the pre-loaded image is made visible?
Answer: Using this JavaScript, you can pre-load the images like this:
<SCRIPT LANGUAGE="JavaScript">
<!--//
// here images are preloaded
onimage = new Image(8,14);
onimage.src = "spiranim.gif";
offimage = new Image(1,1);
offimage.src = "spirit.gif";

function itson(imgDocID,imgObjName) {
        document.images[imgDocID].src = eval(imgObjName + ".src");
         }
//-->
</SCRIPT>

Then, somewhere in the page use this to change the images:

<A HREF="link.html"onMouseOver ="itson('spirit','onimage')"
onMouseOut="itson('spirit',' offimage');">


Click here for more questions, answers, resources, and information about Javascript.
Intranet

Question: I would like to make my company's newsgroup threads into documents that can be placed into our existing "knowledge" database. There they could be searched and displayed by support personnel. What would be the easiest way to do this?
Answer: The easiest way is to use Usenet-to-Web, which should run on any Unix server and lets you publish newsgroups to your Intranet Web server. It even provides a search facility. Best of all, it's free!


Click here for more questions, answers, resources, and information about intranets.
CGI

Question: I am creating pages on the fly using Perl and would like to use frames. I would like to fill the frames using Perl print statements if possible.
Answer: Why not have the link refer to a framed page, one frame (or both) of which is actually dynamically created by the CGI (in the normal way) into the frameset? i.e.

<frameset cols ="40%,*">
<frame name="frame0" src="http://yourdomain.com/cgi-bin/yourcgi">
<frame name="frame1" src="button.htm">
</frameset>

Of course you can have Perl generate the framesets as well, but you have to make sure that the server can do conditional redirection based on the Referer: request header. If this is omitted, an infinite recursion can occur in which the request for the frame content page gets redirected to the frameset page--which causes the browser to make a request for the content page--which again gets redirected to the frameset page. The amount of work it will take you to create a script which can both create the framesets as well as the individual frames within the framesets with the above constraints may cause you to rethink your reasons for doing so, when it can be done as above in about a tenth of the time...


Click here for more questions, answers, resources, and information about CGI.

Have more questions? Ask Dr. Website!



HTML5 Development Center


Recent Articles