better search engine marketing
Return to the Home Page

Designer Help
HTML
Programming



free cut and paste javascripts Free JavaScript

Free JavaScripts

This is a small collection of useful free scripts that we have used over the years. We have chosen easy, cut and paste scripts that will enhance your web site development. Check back as we will be adding to this section regularly.


Index

This simple script allows you make any url open in to a pop up box. You can easily define the size of the window TOOLBAR, MENUBAR, LOCATION RESIZABLE, SCROLLBARS, by using YES or NO. Width and height by changing the numbers with are pixel sizes.

<head>
<script language=JAVASCRIPT>
<!--
function openWindow(theURL, theTitle, theOptions) { //v1.0
var win = window.open(theURL,theTitle,theOptions); return false; }
// -->
</script>
</head>
<body>

Place this remaining function as shown on the url you want to open into a pop up window.

<a href="http://www.kickasp.com "onClick='
return openWindow("http://www.kickasp.com","kickasp","
TOOLBAR=YES,MENUBAR=YES,LOCATION=YES,
RESIZABLE=YES,SCROLLBARS=YES,WIDTH=650,
HEIGHT=300")'> Kick ASP Custom Store Front</a>

</body>

The only known problem with this script is the spacing in the body tag part of the script. When using it in the document make sure there are no extra spaces and keep the entire tag on one line in your html. Don't worry it will fit anywhere.

You can also insert an image along with the hyperlink url. Just before before the </a> insert something like this <img src="my_image.gif" width="125" height="125" alt="my image" border="0"> Be sure to use the border tag or it will produce a blue ring around the image in the Netscape browser's not pretty.


This script opens a perfect window centered in any browser. This to has two parts one the goes between the head tags and the other part the function goes in the body. Very easy to install. This examples use an image. You can not control toolbar, menubar or location with this script which may be a good thing. It provides maximun viewing space for your message with out browser clutter. You can also use the Close Window script, found at the bottom of this page.

This part goes in between the head tags.

<head>
<script language="JavaScript">

<!-- function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',
scrollbars='+scroll+',resizable' win =
window.open(mypage, myname, winprops) if
(parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } // -->

</script>
</head>
<body>

This part goes in between the the body tags.

<a href="http://www.YOUR-URL-HERE.com" target="_top" onclick="NewWindow(this.href,'name','600','400','yes');return false;">
<img src="http://www.YOUR-IMAGE-FILE-HERE.jpg-or-gif" width="88" height="31" alt="Please use this tag" border="0"></a>
</body>

The green '600' controls the width of the window and the blue '400' controls the height you can change these to whatever you want. Don't forget to use the border tag with out it your image will have a blue boarder around it.

Click on this Working Example

CGI programming, database, SQL, PHP

 


Allows your scripts to run in older browsers and if the browser can't handle it your scripts don't produce errors and page opens. Good safety feature if your new to JavaScript.


<script language="JavaScript">
<!-- Hide me from lame browsers

//Put all this stuff in your <HEAD> tags*/
//create a function that will return true function killErrors() {
return true;
}
//use the onError event handler as a property and
//make it equal to the KillErrors function which returns true window.onerror = killErrors;

// -->
</script>


Stop people from taking your images and code! Disables right clicking and ask them to e-mail you for the code. If they click yes it gets their e-mail address. Its a polite way to ask people not to steal. This one is contains layers just change the red areas and make it your own

Click Here to see script in action.

Source Code

This part of the code goes inside the body you can place it anywhere. Note you can change the location of the button that pops up that says "I want your HTML Code". Change the top68px and the left:57px to wherever. The measurement is from the top left corner of the page. The starting point is 0 top, 0 left. You can also change the message part to anything you like I want your HTML Code.

<div id="orderwindow" style="position:absolute;top:
68px;left:57px;visibility:hidden; width: 110px; height: 75px">
<form ACTION="mailto:webmaster@abetterserver.com? subject=I want your HTML Code" enctype="text/plain">
<input type="submit" value="Send for Code" onClick="sendmail()">
</form>
</div>

This GO BACK script goes in-between the HEAD TAGS. When you click on the hyper link in the body counter part you are whisked back where you came from.


<SCRIPT LANGUAGE="JavaScript1.2">
if (window.toolbar.visible) {
document.write('Press the back button to return the previous page.')

}

else {

document.write('<a href="javascript:history.go(-1)"> Click
here</a> to return to the previous page.');

}

</SCRIPT>

Put this in the body were you want your link to go, like the footer.

<a href="javascript:history.go(-1)">Click here</a> to return to the previous page.


This small code will close a pop up window and does not require any other code to be placed in the head section. This should only be used with a pop up window because it will close any window. It works off the codes supplied with browsers.

<a href="javascript:window.close()">Close This Window</a>


This script is so easy its silly! It opens a new window on top of the exisiting window.

<a href="http://www.whatever.com" TARGET="_new"> Your text here</a>


Copy the script and paste it on to your page. You can change the font style as you wish. Its very easy and looks great! If you are viewing this with IE you see it ticking away but if you are viewing in Netscape the clock does not count down but the time is correct.


 
Order Today
Read our Acceptable Uses Policy and Frequently Asked Questions
Need more features? You can add additional features to your account.
   
Add URL  |  Portfolio  | Contact |  Home | Hosting | Links 
 Search Engine Marketing | Site Map |Support | Web Site Designer

A Better Server Search Engine Placement Services
Santa Rosa CA. 95404
Copyright © 1997-2005 (707) 526 0580