Catch the Phillies Phever World Series 2008 Unique Collectibles and T's

Archive for the 'JavaScript' Category

openWYSIWYG

Monday, June 9th, 2008

great text editor controls for users to provide feedback

openWYSIWYG link here 

Form Visibility Event

Tuesday, January 29th, 2008

cool handler to hide/show a text input field…

[ here ]

Site Catalyst Snippet

Saturday, December 15th, 2007
<!– SiteCatalyst code version: G.5.
Copyright 1997-2003 Omniture, Inc.
More info available at http://www.omniture.com –
>
<script language=“JavaScript”>
<!–
/* You may give each page an identifying
name, server, and channel on
the next lines. */
var s_pageName=”"
var s_server=”"
var s_channel=”"
var s_pageType=”"
var s_prop1=”"
var s_prop2=”"
var s_prop3=”"
var s_prop4=”"
var s_prop5=”"
/********* INSERT THE DOMAIN AND PATH TO YOUR
CODE BELOW ************/
//–> </script>

<script language=“JavaScript” src=”
http://REMOTE/token_string/s_code_remote.js ></script>
/// summary --------------------------------------------------------
/// this invokes http://www.fox.com/includes/s_code_remote.js
/// which then in-turn calls
/// http://edge.quantserve.com/quant.js
/// and passes token info for the unique account ID to track
/// then this URI :: http://pixel.quantserve.com
/// sets the spotlight tag for confirmation and analysis
/// which then hits with an intense interrogates requests with
/// //secure.quantserve.com/quant.js
/// http://ak.quantcast.com/js/swfobject.js
/// http://ak.quantcast.com/js/prototype.js
/// http://ak.quantcast.com/js/jquery.pack.js?v=1.1.3.1
/// http://ak.quantcast.com/js/bfograph.js
/// http://ak.quantcast.com/js/quantcast.js
/// + Urchin traking the experience
///  summary  ——————————————————
<script language=“JavaScript”><!–
s_wds(s_account); s_ca(s_account);

function sendAnalyticsEvent(str){
ns=s_account; if(str!=null)ns+=”,”+str;void(s_gs(ns));}

function sendLinkEvent(str,lnkname){
ns=s_account; if(str!=”"&&str!=null)ns+=”,”+str;
s_linkType=”o”; s_lnk=true;
s_linkName=lnkname; void(s_gs(ns));}

//–></script>
<!– End SiteCatalyst code version: G.5. –>

eUpdate

Saturday, April 7th, 2007

This JavaScript is a nice Form handler that detects if the user has modified the form and wants to make sure to update the info for an “e-checkIn/Update” to thier pulled data/account…

cool logic here…

< input type=”hidden” name=”isChanged” id=”isChanged” value=”0″ >

function formChange(){
document.forms[0].isChanged.value=”1″;
}

window.onunload = confirmExit;

function confirmExit() {
if(document.forms[0].isChanged.value==’1′)
return “You’ve not save the form. Are you sure ?”;
}

[ref]

Shadowbox Lightbox Thickbox

Wednesday, October 25th, 2006

heres a good link for lightbox tutorials
http://www.fortysomething.ca/mt/etc/archives/005400.php

heres the link for thickbox
http://jquery.com/demo/thickbox/

Get URL parameter

Monday, October 16th, 2006

If you need to get the passed url to your page and explode it to obtain and return a parameter, youll first have to have mod rewrite working on your server to accept a unconventional string… then once enabled you can catch whats being thrown your way …

< SCRIPT LANGUAGE=”JavaScript” >

function getURLParam(strParamName)
{
var strReturn = “”;
var strHref = window.location.href;

if ( strHref.indexOf(”?”) > -1 )
{
var strQueryString = strHref.substr(strHref.indexOf(”?”)).toLowerCase();
var aQueryString = strQueryString.split(”&”);
for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
{

if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 )
{
var aParam = aQueryString[iParam].split(”=”);
strReturn = aParam[1];
break;
}
}
}

return unescape(strReturn);

document.write(”<br />”+strReturn[1]+”<br />”);

}

</SCRIPT>

Redirecting to New WebPage

Tuesday, August 29th, 2006

window.location = “http://www.yahoo.com/”;

or if you need to give a user choice and hand holding when it comes to redirecting them, use some form handling like below:

form
input type=”button” value=”Go” onClick=”window.location = this.form.url.value”

/form

Looping Arrays

Tuesday, August 29th, 2006

here’s another variety:

var myArray = new Array(3);
// next populate the array containers
myArray[0] = “Item 0”;
myArray[1] = “Item 1”;
myArray[2] = “Item 2”;
// operate the loop
for (i = 0; i < myArray.length; i++)
{
//command the loop for each result of the array
document.write(myArray[i] + “
”);
}

Scheduling A ScriptTask

Monday, August 28th, 2006

you can use setTimeout to call functions

function hello() {
window.alert(“Hello”);
}

window.setTimeout(“hello()”,5000);

remember the handler (in this case is 5000) is measured in milliseconds…

Open the script in a browser. Wait five seconds, and then an alert dialog box should appear. After you close the dialog box, another should reappear after five seconds. This should continue indefinitely.

You can also use the following study to totally clear any scheduled timeout:

window.clearTimeout(myTimeout);

Replacing a Browser Document

Monday, August 28th, 2006

function newDocument() {
document.open();
document.write(“This is a New Document.”);
document.close();
}

< a xhref=”#” onClick=”newDocument()” >
Display New Document
< /a >

Checking passing values

Monday, August 30th, 2004

a cool way Ive found to check to see if my hidden variables are passing through my functions correctly is to see if the containers are returning the proper values by “echoing” anywhere in the script-blocks this simple “echo statement” :

window.alert(myVariable);

OnChange Event

Sunday, August 29th, 2004

This code handles an onChange event - these could be useful in more complicated behavioral coding…. For the detection of the change to occur, most browsers (including all the major ones) don’t actually consider a change to have occurred until the focus leaves the field (such as when the user clicks in another field in the form). If the user didn’t do this, then every time he or she typed a character, the code in the onChange event handler would execute. Instead, the code only executes when a change has occurred and focus has left the field.

> form name=”myForm” <
Enter some Text: >input type=”text” name=”myText” Æ
onChange=”window.alert(this.value);” <
> /form <

When working in the event handler of a form field, the this keyword refers to the object associated with the field itself, which allows you to use this.value instead of document. myForm.myText.value to refer to the text field’s value in the onChange event handler