JavaScript
You are currently browsing the articles from KomKid.Net matching the category JavaScript.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function deleteCookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
} |
Written by Komkid on August 5th, 2009 with no comments.
Read more articles on JavaScript and Programming.
1 2
| fullURL = parent.document.URL
GetVar = fullURL.substring(fullURL.indexOf('?')+xxx, fullURL.length) |
? = variable name
xxx = length of GET variable name.
Example.
1 2
| fullURL = parent.document.URL
GetVar = fullURL.substring(fullURL.indexOf('topicid')+7, fullURL.length) |
Written by Komkid on August 5th, 2009 with no comments.
Read more articles on JavaScript and Programming.
1 2 3 4 5
| var today = new Date();
ThisYear = today.getYear()+0;
if(ThisYear <= 1999){
ThisYear = ThisYear - 100 + 2000;
} |
Written by Komkid on August 5th, 2009 with no comments.
Read more articles on JavaScript and Programming.
Don’t :
1
| if (form.input.value == "") |
Do :
1
| if (form.input.value.length == 0) |
or
1
| if (form.input.value.replace(/\s+$/, "") == "") |
Written by Komkid on August 5th, 2009 with no comments.
Read more articles on JavaScript and Programming.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| /* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Lee Underwood | http://javascript.internet.com/ */
function getFocus() {
// place the id below of the field you want to have focus upon page load
var focusHere = document.getElementById("yourName");
focusHere = focusHere.focus();
}
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
getFocus();
}); |
Written by Komkid on August 5th, 2009 with no comments.
Read more articles on JavaScript and Programming.
No older articles
Newer articles »