Category: Tutorials
Sat
Sep
19

To redirect to a new page, or to reload the one you’re on without using Javascript, you’re going to want to use the following code.

Sat
Sep
19

Today I’m going to show you how to setup a javascript refresh function that can be called whenever you would like to refresh the page. This code can also work as a redirect script.
Lets start with the function…

<script type=”text/javascript”>
function pageRefresh(timeoutPeriod) {
setTimeout(”location.reload(true);”,timeoutPeriod);
}
</script>

Now lets look at the call for this function. This is how you would [...]

Wed
Sep
16

Today I’m going to show you how to make a <div> = the contents of a javascript variable. It’s actually very simple to do!
First lets start with the <div>

<div id=”thediv”></div>

Now lets do the javascript. Areas you will need to change are in bold.

<script type=”text/javascript”>
var thevar = “This is a test“;
document.getElementById(’thediv‘).innerHTML = thevar;
</script>

That will make the [...]

Tue
Sep
08

This ones pretty simple. If you’ve ever wanted to make sure you get a real e-mail address through your input forms, a good way to check an address is by using the following e-mail validation.

if (!eregi(”^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$”, $email)) {
//code here
}

This code will check to make sure that the variable “$email” is in an e-mail format. [...]

Fri
Feb
13

Ever wondered how to create a bookmark feature for your website? This is how to do it. This code only works in IE. It will display a message to other browsers showing them how to bookmark.
Source Code

<script LANGUAGE=”Javascript”>
<!– Begin
if ((navigator.appName == “Microsoft Internet Explorer”) && (parseInt(navigator.appVersion) >= 4)) {
var url=”http://www.snidge.com”;
var title=”Web Design & Development”;
document.write(’<A HREF=”javascript:window.ext’);
document.write(’ernal.AddFavorite(url,title);” [...]

Fri
Feb
13

Wondering how to make a simple javascript navigation back link to place on your website? This code will take the user -1 in the browser history. You can change the value to whatever you would like.
Use it as a link:

<a href=”#” onClick=”history.go(-1)”>Back</a>

Use it as a button:

<input type=button value=”Back” onClick=”history.go(-1)”>


  Copyright © 2009 Snidge.com. All rights reserved.