Bits -o- Code

Reference
Bare Bones Guide to HTML v3.0 - Good guide to the basics. Opens in a new browser window


Last Modified Date of Page - Javascript
The following JavaScript will put the LastModified date of the current file where ever you put this code. Has to be in the <BODY></BODY> section.

<FONT SIZE="-1" face=arial >
<SCRIPT LANGUAGE="JavaScript">
     var theDate = ""
     theDate = document.lastModified
     document.write("      Last Updated:");
     document.write(theDate);
     document.write();
</SCRIPT>
</FONT>


Refresh Code - Automatically forward to a new web site/page
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://NEW URL">
<html>
<head>
<title>Title Goes Here<title>
<head>
<body> Sorry! We have moved to
<a href = "http://NEW URL">http://NEW URL</a>
</body>
</html>


Returns to previous page - Javascript
<a href="javascript://" onClick="history.go(0)" onMouseOver="window.status='STATUS BAR MESSAGE GOES HERE'; return true" onMouseOut="window.status=''; return true"><img src="SOME GRAPHIC FILE" height=X width=Y border=0>OR SOME TEST FOR THE LINK</A>

Another format of the same thing:

<A HREF="javascript:history.back()">Return to Previous Document</A>


Mouseover status bar example - Javascript
<a href="http://LINK LOCATION" onMouseOver="window.status='STATUS BAR MESSAGE GOES HERE'; return true" onMouseOut="window.status=''; return true">


JavaScript Refresh - Just like the META REFRESH, but search engines don't hate them as bad from what I have read.
<SCRIPT language="Javascript"> setTimeout('location.href="http://YOUR_DESTINATION_URL_GOES_HERE"',0); </SCRIPT>
The 0 at the end is the number of seconds to wait before transporting the user to the next page.


Creates little diamond-like thingie
<table border=7><tr><td></td></tr></table>
See:


Set default FONT for PC & Mac
In your FONT tag, if you are using FACE="Arial", change it to FACE="Arial,Helvetica" so you don't leave Mac users out.


HTML code for automatically refreshing to next page
Place:

< META HTTP-EQUIV="Refresh" CONTENT="XXX; URL=http://YYY" >

in your <HEAD> </HEAD> statement.

Replace XXX with how many seconds ( 0 for instant ) and replace YYY with the URL to the new location.

WARNING! This will hurt your Search Engine ranking, most likely getting the URL removed from the database next time it gets spidered. Just a warning!


Stop browsers from pulling your page from cache
If you add:
< meta http-equiv="Pragma" content="no-cache">
In the HEAD section, the browser will pull a fresh copy every time. Or at least it is supposed to. :-)


ERROR 404
Create a custom 404 error page. Put a .htaccess file in the main dir. The file only contains this text:
ErrorDocument 401 /error_page.shtml
ErrorDocument 403 http://www.yourdomain.com/error_page.shtml
ErrorDocument 404 http://www.yourdomain.com/error_page.shtml
ErrorDocument 500 http://www.yourdomain.com/error_page.shtml
Replace yourdomain with, what else, your domain!


Stop IE5 from steaking your 404 page traffic
If you have a custom 404 error page, be aware that IE5 tries to take the traffic from it and give it to Microsoft. Read this Microsoft artcle and make sure your error message pages are larger than the ones below to prevent this!
   400: 512 bytes
   403: 256 bytes
   404: 512 bytes
   405: 256 bytes
   406: 512 bytes
   408: 512 bytes
   409: 512 bytes
   410: 256 bytes
   500: 512 bytes
   501: 512 bytes
   505: 512 bytes


Translate your page!
Not exactly code, but if you have a site with much international traffic, it might be a good idea to create more than one version of it (or parts) in different languages. Best FREE resource is at AltaVista's Bablefish.


Add sound to your page!
Want to have a message play automatically when your page loads? Add:

<bgsound src="yourmessage.wav" loop="1">

in the <BODY> tag. Just don't have it too loud or too large!


Real Audio Trick - How to use Real Audio without a Real Audio Server
Once you have created your .ra file, FTP it to your server, and create a file with a .ram extension. This is just a standard text file, and will contain the following:

pnm://yourdomain/path_to_the_real_audio_file

So for test.ra in the realaudio directory on domain.com, you would place the following in test.ram:

pnm://domain.com/realaudio/test.ra

When they click on the .ram file, it will spawn the Real Audio player and you are done!


Break out of frames
Set your target paramter to _top to break out of someone elses frames.

<A HREF="http://www.domain.com" TARGET="_top">Break out of frames!</a>


JavaScript BACK button
Use JavaScript to create a FORM button that will take you back to the previous page you were on.
Change value to whatever you want the button to say.

<FORM>
<INPUT type="button" value="Back" onClick="history.go(-1)">
</FORM>

Example:


Use Javascript to emulate MAILTO:
Use the following code to prvent email spiders from putting you on ANOTHER email list!

<script language="JavaScript">
document.write('<a href="mailto:' + 'NAME' + '@' + 'DOMAIN.COM' + '">');
document.write('NAME' +'</a>');
</script>


Make new browser window open FULL SCREEN
This little JavaScript snippet will make the browser open full screen. Probably only works for 4.0 browsers, but won't hurt others. Place it inthe HEAD of the page you want to open full screen.

<script language="JavaScript">
<!--
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
//-->
</script>


Insert AVI on page
Use the following line to insert a AVi on a web page. Set the
autostart= to false if you do not want it to play on load.

<EMBED src="filename.avi" width=160 height=120 border=0 autostart=true>


Make background image FIXED
How to get the background image to stay fixed in place, and not scroll.
This is IE only.


Make Spiders index your WHOLE site!
Here is the meta tag that tells the robot spiders to follow all the links to your other pages:

<meta NAME="ROBOTS" CONTENT="FOLLOW, INDEX">


Use FORM buttons for Navigation
<form action="http://www.webspawner.com/"> <input type="submit" value="YOUR TEXT HERE">
</form>


Me Wife Home

© rusty
[an error occurred while processing this directive]