Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Sasha http://nothing-less.net

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

clear default text onClick - restore if nothing entered

From ScriptyGoddess:
http://www.scriptygoddess.com/archives/2005/11/15/clear-default-text-onclick-restore-if-nothing-entered/

In your document's head:
<script type="text/javascript">
function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}
function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}
script>


The actual form field:
<input type="text" name="myfield" onclick="clickclear(this, 'default text')" onblur="clickrecall(this,'default text')" />

Back and Forward Links in History

Using form buttons:

<form>
<input type="button" value="Back" onclick="history.back()">
<input type="button" value="Forward" onclick="history.forward()">
<input type="button" value="Reload" onclick="location.reload()">
form>


Using a normal link:

<a href="javascript:history.back();">Backa>


« Newer Snippets
Older Snippets »
2 total  XML / RSS feed