Free Javascript Samples

Add dynamic javascript samples to your website. Simply cut and paste our free Javascript samples to your site.

Javascript

Javascript runs on your visitor's web browser provided they have it enabled. Most do.

Javascript responds to events like a mouse moving over an image or link, the page loading, a button click etc.

Simple Javascripts will be added in the body part of your web site. Frequently used functions are put in the head section.

To tell the web browser what to do and to hide the code from old browsers, we wrap our Javascript code up like this:

<script language="Javascript">
<!--
Place your Javascript code here
//-->
</script>


Image Search Selection Code

This gives a list of celebs to choose from. Clicking on show pics opens a new window with image search results from Yahoo!

It's easy to add or modify the list of celebs with your own selection.

Please retain the link-back to Urgentclick.com when using this script :-)

Mouse-over effects

Use this code to display a message in the status area of the web browser when a mouse hovers over a hypertext link.

<a href="mypage.html"
onMouseOver="window.status='The message'; return true"
onMouseOut="window.status=''; return true" >
The text of the link</a>

Note: window.status='' uses single quotes.


Display the date and time.

<script type="text/javascript">
<!--
document.write(Date())
//-->
</script>


Alert the visitor

This code pops up an alert box when your page loads.

<script type="text/javascript">
<!--
alert("This site may contain annoying Javascripts!")
//-->
</script>


Javascript Popup Window

<script type="text/javascript">
<!--
window.open('mywindow.html', 'Window Title', 'width=150,height=150')
//-->
</script>


Javascript Close Window

This code:

Click <a href="" onClick="window.close()">here</a> to close the window.<p>

Displays this: Click here to close the window.


Javascript Frame Escape

This code makes a page jump out of a frame. It helps stop other sites framing a page.

<script language="JavaScript" for="window" event="onLoad()">
if (top.location != location) {
top.location = "index.html";
}
</script>


Meta Tag to stop Robots Crawling and Indexing a Page

<META NAME="robots" CONTENT="noindex">


Javascript Pop Behind Window

This code makes a pop-up window hide behind the main window. It does this by popping up a window which normally gets focus and then returning the focus back to the original page.


Javascript Referring Website URL Redirect / Blocker

This code checks the referring website URL against a list of strings. If any of the strings are contained in the URL then the browser is redirected to another web page.

This is useful where another site is deeplinking to a page and you don't want it to happen for example.

Edit the sites array with your own list of strings. In this example, any visitor from a page on msn.com would be redirected to another-page.html Also, any visitor from a page with deeplink in the url would be redirected.


Home

Copyright © 2005 Urgentclick.com