Jan
11
2010
//tell javascript to run a function in 1 second
setTimeout ("myFunction()", 1000 );
function myFunction(){
//do stuff
//once the function is finished, queue this function up to run again in 1 second
setTimeout ( "myFunction()", 1000 );
}
1 comment | tags: HTML, internet, Javascript, useful | posted in Javascript, Tips, Web Development, usability
Sep
12
2009
Google doesn’t make it easy to show you the latitude and longitude of an address you search in google maps, but there’s an easy way to get the info.
- go to google maps, type the address, and click search
- once you’ve found it, go to your address bar and clear what’s in it
- paste:
javascript:void(prompt('',gApplication.getMap().getCenter())); into the address bar
- use the coordinates for whatever you wish!
no comments | tags: HTML, internet, Javascript, useful, work | posted in Javascript, Tips, Web Development, usability
May
6
2009
So, wouldn’t it be user friendly, if when you went to a form page in a document, if the cursor was automagically positioned at the first field in the form?
Why, yes it would. Try:
Event.observe(window, 'load', function(){
try {
$('eventName').focus();
}
catch (e) {}
});
after your </form> tag. This requires the prototype javascript library
no comments | tags: internet, Javascript, useful, work | posted in Javascript, Tips, Web Development, usability
Apr
24
2009
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function duplicateField(field1, field2){
var theLength = document.getElementById(field1).value.length - 1;
var theString = document.getElementById(field1).value;
for(var i=0; i < theString.length-1; i++){
if(theString.charAt(i) == " "){
theString = setCharAt(theString, i, "_");
}
}
document.getElementById(field2).style.color = "#c9c9c9";
document.getElementById(field2).value = theString;
}
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
}
function changeColorBack(fieldName){
document.getElementById(fieldName).style.color = "#000000";
}
</script>
</head>
<body>
<p>
<input id="field1" onkeyup="duplicateField('field1', 'field2');" type="text" />
</p>
<p><br />
<input id="field2" type="text" onfocus="changeColorBack('field2');" /><br />
</p>
<p>
<span id="span1"></span>
<input id="submitButton" type="submit" value="Submit" />
</p>
</body>
</html>
no comments | tags: HTML, internet, Javascript, Wordpress | posted in Javascript, Web Development, Wordpress