Song Lyrics A to Z - Debt Consolidation - VeraciTek, Inc. - We Build Websites - Debt Consolidation - Find jobs

PDA

View Full Version : Some JavaScript Tips


Jasonb
Dec 3rd 2006, 8:02 am
hey guys!
Want to add smth on your site?
Here are some tips:

1. Dynamic Title Bar
<!-- ONE STEP TO INSTALL DYNAMIC TITLE BAR:

1. Copy the coding into the HEAD of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var message = new Array();
// Set your messages below -- follow the pattern.
// To add more messages, just add more elements to the array.
message[0] = "Message 1";
message[1] = "Message 2";
message[2] = "Message 3";
message[3] = "Message 4";


// Set the number of repetitions (how many times the arrow
// cycle repeats with each message).
var reps = 2;
var speed = 200; // Set the overall speed (larger number = slower action).

// DO NOT EDIT BELOW THIS LINE.
var p = message.length;
var T = "";
var C = 0;
var mC = 0;
var s = 0;
var sT = null;
if (reps < 1) reps = 1;
function doTheThing() {
T = message[mC];
A();
}
function A() {
s++;
if (s > 8) { s = 1;}
// you can fiddle with the patterns here...
if (s == 1) { document.title = '||||||====||| '+T+' -----'; }
if (s == 2) { document.title = '|||=|||===||| '+T+' -----'; }
if (s == 3) { document.title = '|||==|||==||| '+T+' -----'; }
if (s == 4) { document.title = '|||===|||=||| '+T+' -----'; }
if (s == 5) { document.title = '|||====|||||| '+T+' -----'; }
if (s == 6) { document.title = '|||===|||=||| '+T+' -----'; }
if (s == 7) { document.title = '|||==|||==||| '+T+' -----'; }
if (s == 8) { document.title = '|||=|||===||| '+T+' -----'; }
if (C < (8 * reps)) {
sT = setTimeout("A()", speed);
C++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) mC = 0;
sT = null;
doTheThing();
}
}
doTheThing();
// End -->
</script>

2. Week Day Image



<!-- TWO STEPS TO INSTALL WEEK DAY IMAGE:

1. Copy the coding into the BODY of your HTML document

STEP ONE: Paste this code into the BODY of your HTML document

STEP TWO: Copy the images from images folder of this program, or
use your own using the same naming scheme -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>




3.Date and Time Stamp
<!-- ONE STEP TO INSTALL DATE & TIME STAMP:

1. Paste the coding into the BODY of your HTML document -->

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->

<BODY>

<CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) year = 1900 + year;
document.write('<font size="2" face="Arial">' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + '</font><BR>');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
document.write('<font size="0" face="Arial">' + Hours + ":" + Mins + Time + '</font>');
// End -->
</SCRIPT>
</center>




4. No Right Click
<!-- ONE STEP TO INSTALL NO RIGHT CLICK:

1. Copy the coding into the HEAD of your HTML document

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript1.1">
<!-- Begin
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click");
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
// End -->
</script>



5. Expanding Window
<!-- TWO STEPS TO INSTALL EXPANDING WINDOW:

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>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function expandingWindow(website) {
var heightspeed = 2; // vertical scrolling speed (higher = slower)
var widthspeed = 7; // horizontal scrolling speed (higher = slower)
var leftdist = 0; // distance to left edge of window
var topdist = 0; // distance to top edge of window
if (document.all) {
var winwidth = window.screen.availWidth - leftdist;
var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
sizer.location = website;
}
else
window.location = website;
}
// End -->
</script>
</Head>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<a href="enter.html" onClick="expandingWindow('enter.html');return false;">Click here to enter</a>




7. Random Page
<!-- ONE STEP TO INSTALL RANDOM PAGE:

1. Copy the coding into the HEAD of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var howMany = 2; // max number of items listed below
var page = new Array(howMany+1);

page[0]="http://www.anysite.com";
page[1]="http://www.anothersite.com/page.html";

function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</SCRIPT>
</HEAD>





8. Browser Information
<!-- TWO STEPS TO INSTALL BROWSER INFORMATION:

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>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var navName = navigator.appName ;
var brVer = navigator.userAgent; var brNum; var reg = new RegExp('/');
function verNumIE() {
var brVerId = brVer.indexOf('MSIE');
brNum = brVer.substr(brVerId,8);
}
function verNumOt() {
var brVerId = brVer.search(reg);
brNum = brVer.substring(brVerId+1);
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
if (navigator.appName == 'Microsoft Internet Explorer') {
verNumIE() ;
} else {
verNumOt() ;
}
document.write("<CENTER>");
document.write("<TABLE BORDER=2>");
document.write("<CAPTION Align=Top><b>Your Browser Informations</b></CAPTION>");
document.write("<Tr>");
document.write("<td bgcolor=#C0C0C0><b>Browser Name : </b></td>");
document.write("<td>",navName,"</td>");
document.write("</Tr>");
document.write("<Tr>");
document.write("<td bgcolor=#C0C0C0><b>Platform Name : </b></td>");
document.write("<td>",navigator.platform,"</td>");
document.write("</Tr>");
document.write("<Tr>");
document.write("<td bgcolor=#C0C0C0><b>Browser Version : </b></td>");
document.write("<td>",brNum,"</td>");
document.write("</Tr>");
document.write("<Tr>");
document.write("<td bgcolor=#C0C0C0><b>Is Java enabled ? : </b></td>");
if ( !(navigator.javaEnabled()) ) {
java="No" ;
} else {
java="Yes" ;
}
document.write("<td>",java,"</td>");
document.write("</Tr>");
document.write("</TABLE>");
document.write("</CENTER>");
// End -->
</script>




9. Referrer
<!-- ONE STEP TO INSTALL REFERRER:

1. Copy the coding into the BODY of your HTML document -->

<!-- STEP ONE: Add this code into the BODY of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

// The referrer info is only printed out when you
// follow a link to the page with this script on it!

if (document.referrer) {
document.write("Thanks for visiting us from ");
document.write(document.referrer);
}
// End -->
</SCRIPT>




10. Write and Slide
<!-- TWO STEPS TO INSTALL WRITE AND SLIDE:

1. Copy the coding into the HEAD of your HTML document
2. Copy the coding into the body tag HTML document -->

<!-- STEP ONE: Add this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var Message="My cool website";
var place=1;
function scrollIn() {
window.status=Message.substring(0, place);
if (place >= Message.length) {
place=1;
window.setTimeout("scrollOut()",300);
} else {
place++;
window.setTimeout("scrollIn()",50);
}
}
function scrollOut() {
window.status=Message.substring(place, Message.length);
if (place >= Message.length) {
place=1;
window.setTimeout("scrollIn()", 100);
} else {
place++;
window.setTimeout("scrollOut()", 50);
}
}
// End -->
</SCRIPT>

<!-- STEP TWO: Add this code to the BODY tag -->
<body onLoad="scrollIn()">




11. Confirm Entry
<!-- ONE STEP TO INSTALL CONFIRM ENTRY:

1. Copy the coding into the HEAD of your HTML document -->

<!-- STEP ONE: Add this code into the HEAD of your HTML document -->
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var agree=confirm("Do you wish to continue?");
if (agree)
document.write("");
else
history.go(-1);
// End -->
</SCRIPT>





12. Welcome Cookie
<!-- ONE STEP TO INSTALL WELCOME COOKIE:

1. Copy the coding into the HEAD of your HTML document -->

<script language="javascript">
<!--
readCookie();

function readCookie() {
if (document.cookie == "") {
writeCookie();
alertMessage();
} else {
var the_cookie = document.cookie;
the_cookie = unescape(the_cookie);
the_cookie_split = the_cookie.split(";");
for (loop=0;loop<the_cookie_split.length;loop++) {
var part_of_split = the_cookie_split[loop];
var find_name = part_of_split.indexOf("nfti_date")
if (find_name!=-1) {
break;
} // Close if
} // Close for
if (find_name==-1) {
writeCookie();
} else {
var date_split = part_of_split.split("=");
var last = date_split[1];
last=fixTheDate(last);
alert ("Welcome, Your last visit was on: "+last);
writeCookie();
} // Close if (find_name==-1)
}
} // Close function readCookie()

function writeCookie() {
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "nfti_date="+escape(today);
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
}

function alertMessage(){
alert ("Welcome, This is your first visit here.")
}

function fixTheDate(date) {
var split = date.split(" ");
var fix_the_time = split[3].split(":")
var hours = fix_the_time[0]
if (hours>=12) {
var ampm="PM"
} else {
var ampm="AM"
}
if (hours > 12) {
hours = hours-12
}
var new_time = hours+":"+fix_the_time[1]+" "+ampm
var new_date = split[0]+" "+split[1]+", "+split[2]+" at "+new_time+", "+split[5]
return new_date;
}
//-->
</script>



13. Marquee
<!-- ONE STEP TO INSTALL MARQUEE SCROLL:

1. Paste the coding into the BODY of your HTML document -->

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
mesg = "A great way to get them to see somthing important";
isNS = (navigator.appName == "Netscape")
isIE = (navigator.appName == "Microsoft Internet Explorer")
text = ("<i><font size=0>"+mesg+"</font></i>")
if (isNS) {
document.write("<blink>" + text + "</blink>")}
else if (isIE) {
document.write("<MARQUEE BEHAVIOR=ALTERNATE DIRECTION=RIGHT>" + text + "</MARQUEE>")}
// End -->
</SCRIPT>
<NOSCRIPT>
<i><font size=0>A great way to get them to see somthing important</font></i>
</NOSCRIPT>



Enjoyed them? want some more? add to my reputation

the_pm
Dec 4th 2006, 4:29 am
Perhaps the next time you republish a whole bunch of scripts written by other people you'll be kind enough not to remove their copyright and contact information from their scripts.

Dynamic Title Bar - http://javascript.internet.com/page-details/dynamic-title-bar.html

Date and Time Stamp - http://javascript.internet.com/page-details/date-time-stamp.html

Browser Information - http://javascript.internet.com/user-details/browser-details.html

That's enough from me. The others are stolen as well - anyone can look them up in the search engine of their choice and see it too.

As requested I've given you reputation. You're not going to like it, but it is quite appropriate given the contents of your post. Post reported too.

techblog
Dec 4th 2006, 4:32 am
please tell us exactly what each one does

the_pm
Dec 4th 2006, 4:35 am
please tell us exactly what each one doesAlmost all of these scripts originated on http://javascript.internet.com/ . They all come with detailed descriptions there (and the copyright information OP conveniently erased from the scripts).

Jasonb
Dec 4th 2006, 4:42 am
I didn't get them from there... I reently bought a JavaScript software...didn't know...sorry

010081
Dec 4th 2006, 5:02 am
thankx for the code ,i was in need of Referrer code.

the_pm
Dec 4th 2006, 6:09 am
I didn't get them from there... I reently bought a JavaScript software...didn't know...sorryThen please post the TOS provided by the software company that explicitly gives you permission to reprint the scripts they were distributing without attributing the content to them. Once you've done this, I'll check with Jupiter Media (owners of internet.com) and see whether the software company you speak of had permission to distribute the scripts published on their site with copyrights removed.

Even if your story is true (and for what little it's worth, I don't believe a word of it), you're still reprinting someone else's work without permission in order to receive reputation, and that's just low. But I'll give you the benefit of the doubt long enough to allow you to prove that: 1) there really is a "software company" from whom you received a bunch of scripts, 2) they obtained the scripts legally and edited them with permission of the authors, and c) they've granted you permission to republish them without providing any credit or copyright information about them or the original authors.

Even if you can verify your story, you still don't deserve reputation for someone else's work. But this is your opportunity to prove that you don't deserve negative rep.

Enjoyed them? want some more? add to my reputationCareful what you ask for, because you might just get it...

Jasonb
Dec 4th 2006, 6:12 am
ok... thanks for telling me then... then, I think this topic should be removed...