Web Designer's Killer Handbook™
The Web Designer's Killer Handbook is not intended to teach total beginners how to use each of these key technologies; rather the goal is to filter out some of the more useful techniques and code that I have found throughout the years when creating websites and web applications.
Heavy water: H20 has one more hydrogen atom than regular water.
Heavy water: H<sub>2</sub>0 has one more hydrogen atom than regular water.
Both subscript and superscript are examples of code that does not get any easier except for maybe <hr> , the horizontal rule. But I decided to include them here after I found that some very experienced web designers did not know about them!
This book is published by Killersites.com.
This book is published by Killersites.com<sup>™</sup>.
Prevent the page from jumping
Non-Jumping page link.
Non-Jumping <a href="#" onClick="alert('This is a message.'); return false;">page link.</a>
For those non-nerds out there, 'calling a function' is basically asking the browser to take an action. Sometimes these 'actions' (functions) are built in like the 'alert' function I mentioned above, and other times these 'actions' are created by you or other programmers. Don't worry about the function stuff now, it is not really important for our discussion here.
Cause the page to jump
Jumping page link. (Be careful, when this link is clicked your page will jump)
Jumping <a href="#" onClick="alert('This is a message.');">page link.</a>
In the above code samples you will notice that after you click the first link the page stays put, whereas when the 2nd link is clicked the page jumps to the top. The first link does not jump because of this code inside the onClick event handler:
Obfuscated email address to protect yourself from spam
Spammers often send out webbots to scrape email addresses listed on web pages. This is a sample of an obfuscated (in other words: encoded) email address to protect yourself from spam.
<a href="mailto:nudioweb.com">my email</a>
Jump to a spot on another page
<a href="../find_PHP_host_step2.jsp#make_php_page">Jump to spot</a>
You can set what is called an anchor point in your pages with the following code :
<h1 id="myAnchor">My Anchor</h1>
Add the id to any element in your page, and then refer to this anchor within the same page (as seen at the top of this page: <a href="#book"> Jump to the book </a> ) or from another page by appending the number symbol : # and the anchor name to the URL of the page. In the above example I am jumping to the 'articles' anchor in the page 'indexCommunity.htm'
ASCII Character Code
ASCII character codes allow you to insert special character into your HTML pages that you can't normally find on your keyboard. Having this list can prove to be very useful on some web jobs.
Removing the %20 in URL's
Recently, someone was wondering why the browser kept inserting this text in his URLs: %20. This code (%20) tells the browser there is a white space in between the text. Take for example the following html file that someone created and named:
The browser will insert the code %20 in the URL to deal with the space in the file 'top ten.htm' like so:
The bottom line is that there should be no white spaces in an url, and that includes your HTML file names. Sometimes people make this mistake of leaving a space because the name of the file would be hard to read otherwise. A good trick around this is to capitalize the second word in the file name and to keep the first letter of the first word in lower case:
This is a common way to name files and is very popular with Java programmers (I do a lot of Java work and that is where I get it from… but it is not strictly a Java thing).
Add to favorites: How to create an 'add to favorites' link
This little code snippet allows you to present a link that when clicked will add your page to the user's list of favorites. The following example uses a text link, but you could also swap up the text for an image if you are creating a graphical button.
<a href="#" onClick='window.external.AddFavorite(location.href, document.title); return false'>Add to favorites</a>
The next code tip creates a link button that when clicked sets your page as the user's home page. Like any html link, you can insert an image instead of the text to create a button link.
<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.killersites.com'); return false">Make home page</a>
Of course you will have to replace the text:
You need to insert your own website address, otherwise people will be making killersites.com their home page.
Here is an example of a link made with an image instead of text:
<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.killersites.com'); return false"><img src="myImages.gif" border="0"/> </a>
One important thing I should point out is that when inserting an image into a hyperlink as we just did, you need to specify a border of zero (0):
<img src="myImages.gif" border="0"/>
Otherwise you will get an ugly looking border around the image.
I've only tested the "Add to Favorites" code in IE; you never know how code will react in every which browser, so I dug up this script that only allows people using IE to automatically "Add to Favorites". If the user is not using IE this script will cause a Java Script pop-up window to appear when the link is clicked, asking them to do it manually. In a nutshell: the link will appear in all browsers, but will only allow IE users to save the page as a favorite.
// The browser is Internet Explorer so we open the 'add favorite' window
// Add the document location and title to the AddFavorite window
alert("Sorry, your browser doesn't support this feature." +
"\nPlease use the bookmark feature of your browser to save the location of this page.");