| |
|
|
| |
- Add the date
- Creating a pop-up
window
- Bookmark
this page
- Print this page
- Right click
disabled
- Scrolling Footer
Message
- News scroller
- Tell a friend
- Finding pre-made
sripts
|
| |
| 1. Adding the Current Date to
Your Web Pages |
| In the
upper right hand corner of each of the L2D web pages you
will find the current date. The JavaScript we use can be
found below. Just copy it and paste it where you want the
date to appear on your pages. It's that simple!
|
<script>
/*Current date script credit:
JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October",
"November",
"December")
document.write("<small><font color='000000'
face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")
</script>
|
| |
2. Creating a pop-up
window
Back
to top
Try it here:
Launching a specific sized window a specific window size
JAVAscript Language
Declaration goes in the document head:
<SCRIPT
LANGUAGE="JavaScript1.1"> javascript_version
= 1.1;</SCRIPT>
<SCRIPT TYPE="text/javascript" CHARSET="ISO-8859-1">
var newwin;
function
launchwin(winurl,winname,winfeatures)
{
//This launches a new window and then
//focuses it if window.focus() is supported.
newwin = window.open(winurl,winname,winfeatures);
if(javascript_version > 1.0)
{
//delay a bit here because IE4 encounters errors
//when trying to focus a recently opened window
setTimeout('newwin.focus();',250);
}
}
</SCRIPT>
Action
Goes in the document body:
<p><font face="Verdana,
Arial, Helvetica, sans-serif" size="-1"><a
href="javascript:launchwin('popup.htm','newwindow',
'height=219,width=257')">Using a specific
window size</a></font></p> |
| |
3.
Bookmark this Page
Try it Here: Bookmark
This Page
Requires
2 steps for installation:
1. Copy the coding into the
HEAD of your HTML document
2. Add the last code into the BODY of your HTML
document -->
<!-- STEP ONE: Paste
this code into the HEAD of your HTML document
-->
Be sure to change the
URLs so they point to your website.
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available
free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com
-->
<!-- Original: Prakash -->
<!-- Web Site: http://www20.brinkster.com/mahathmaonline/bookmark.html
-->
<!-- Begin
function addbookmark()
{
bookmarkurl="http://wwwJavascriptsource.com"
bookmarktitle="Welcome To The Java Script
Source"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
// End -->
</script>
<!-- STEP TWO: Copy
this code into the BODY of your HTML document
-->
<a href="javascript:addbookmark()"><b>Bookmark
This Page</a>
|
|
4. Print this Page
Back
to top
Just paste this script where you want the link
to appear.
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
if (window.print) {
document.write('<form>Click Here To '
+ '<input type=button name=print value="Print"
'
+ 'onClick="javascript:window.print()">
This Page!</form>');
}
// End -->
</script> |
|
5. Right Click DisabledBack
to top
Go ahead and try to right click this page.
Just paste this code in the head of your document:
<script
language=JavaScript>
function clickIE() {
if (document.all) {
return false;
}
}
function clickNS(e) {
if (document.layers||(document.getElementById&&!document.all))
{
if (e.which==2||e.which==3) {
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
}
else{
document.onmouseup=clickNS;
document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return
false")
</script> |
|
6. Scrolling Footer
Message
Back
to top
Just paste this code in the <head>
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
function scrollit(seed) {
var m1 = "Professional designers create your
website! ";
var m2 = "Try it now! ";
var m3 = "Quality proven designs to sell
your products or service! ";
var m4 = "";
var msg=m1+m2+m3+m4;
var out = " ";
var c = 1;
if (seed > 100) {
seed--;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 100 && seed > 0)
{
for (c=0 ; c < seed ; c++) {
out+=" ";
}
out+=msg;
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 0) {
if (-seed < msg.length) {
out+=msg.substring(-seed,msg.length);
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else {
window.status=" ";
timerTwo=window.setTimeout("scrollit(100)",75);
}
}
}
// End -->
</SCRIPT>
Add this onLoad event to the
BODY tag.
onLoad="scrollit(100)"
|
|
7. News Scroller
<!-- TWO STEPS TO INSTALL LEN'S NEWS SCROLLER:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML
document --> <!--
STEP ONE: Paste this code into the HEAD of your
HTML document -->
<HEAD>
<!-- This script and many more are available
free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com
-->
<!-- Original: Len Dierickx (webmaster@n.one.port5.com)
-->
<!-- Web Site: http://n.one.port5.com -->
<script type="text/javascript">
//<![CDATA[
<!--
function scrollerObj(name,initH,initW,heightB,widthB,content,initBg,Bg,
speed,initFl){ //**data**//
this.name=name;
this.initH=initH;
this.initW=initW;
this.heightB=heightB;
this.widthB=widthB;
this.content=content;
this.initBg=initBg;
this.Bg=Bg;
this.iniFl=initFl;
this.speed=parseInt(speed);
this.timer = name + "Timer";
this.elem;
//**methods**//
this.getElement = getElement;
this.createLayer=createLayer;
this.scrollLayer = scrollLayer;
this.scrollLoop=scrollLoop;
//**initiate methods**//
this.createLayer();
this.getElement();
this.scrollLayer();
}
//**call this method to stop scrolling**//
function scrollLoop(s){
this.speed = s;
}
//**pretty obvious**//
function scrollLayer(){
if(parseInt(this.elem.style.top)>(this.elem.offsetHeight*(-1))){
this.elem.style.top = parseInt(this.elem.style.top)-this.speed;
//alert(parseInt(this.elem.style.top)+"\n"+this.elem.id);
}
else {this.elem.style.top = this.initH;}
}
//**get the specific dom-expression**//
function getElement(){
if(document.getElementById){
this.elem = document.getElementById(this.name);
}
else if (document.all){
this.elem = document.all[name];
}
else if (document.layers){
this.elem = document.layers[name];
}
}
//**pretty obvious - if NS4 - please upgrade to
a standard compliant browser**//
function createLayer(){
if(document.getElementById || document.all){
document.write('<div id="layer'+this.name+'"
style="position:relative;overflow:hidden;float:'+this.initFl+';background-color:#'+this.initBg+';border:1px
solid black;width:'+this.initW+'px;height:'+this.initH+'px;"
onMouseover="'+this.name+'.scrollLoop(0)"
onMouseout="'+this.name+'.scrollLoop('+this.speed+')">');
document.write('<div id="'+this.name+'"
style="position:absolute;top:'+this.initH+'px;left:0px;border:0px
solid black;width:'+this.widthB+'px;height:'+this.heightB+'px;background-color:#'+this.Bg+'">');
document.write(this.content);
document.write('<\/div><\/div>');}
else if(document.layers){
document.write('<ilayer name="'+this.name+'"
bgcolor="#'+this.Bg+'" width="'+this.widthB+'"
height="'+this.heightB+'">'+this.content+'<\/ilayer>');
return;
}
if(this.scrollLayer){
this.timer = setInterval(this.name+'.scrollLayer()','30');
}
}
//-->
//]]>
</script>
</HEAD>
<!-- STEP TWO:
Copy this code into the BODY of your HTML document
-->
<BODY>
<!-- This script and many more are available
free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com
-->
<!-- Original: Len Dierickx (webmaster@n.one.port5.com)
-->
<!-- Web Site: http://n.one.port5.com -->
<div align="center">
<script type="text/javascript">
//<![CDATA[
<!--
var c = new scrollerObj('c','300','100','50','100','<h1>news
scroller<\/h1><p class="text">This
scroller code will allow you to put several newsboxes
on your site. You can put any valid html in the
box, including images.<\/p><p class="text">Please
note that when you put the newscroller in a table,
this will not work in Mozilla. When you hover
your mouse over the box when running Mozilla:
not working either. If anybody knows whats going
on please <a href="mailto:webmaster@n.one.port5.com">mail
me<\/a><\/p>','FFDD00','cccccc','2','center');
//-->
//]]>
</script>
</div>
<p>
<center>
<font face="arial, helvetica" size"-2">Free
JavaScripts
provided<br>
by <a href="http://javascriptsource.com">The
JavaScript
Source</a></font>
</center>
<p>
</BODY>
|
| |
8. Tell a friend Back
to top
Part 1 - enter
inside your head tags
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//Tell-a-friend
script
//Carl Dimmer
var
initialsubj="Hay buddy, take a look at this"
var initialmsg="Hi:\n You may want to check
out this site: "+window.location
var good;
function checkEmailAddress(field) {
var
goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|
(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid address.');
field.focus();
field.select();
good = false;
}
}
u = window.location;
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.email);
if (good) {
//window.location
= "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+
document.title+" "+u; window.location
= "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+
initialmsg
}
}
// End -->
</script>
Part 2 - enter in your page body where you want
the script to display
<form
name="eMailer">
Tell a friend:
<input type="text" name="email"
size="26" value=" Enter Address
Here" onFocus="this.value=''" onMouseOver="window.status='Enter
email address here and tell a friend about this
site...'; return true" onMouseOut="window.status='';return
true">
<br>
<input type="button" value="Send
this URL" onMouseOver="window.status='Click
to send an email (with this page address) to a
friend! Enter email address above...'; return
true" onMouseOut="window.status='';return
true" onClick="mailThisUrl();">
</form>
|
| |
|
| |
|
 |
|
|