The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed
 
member picmember pic
 
Snippets of ALBERTO
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Javascript Event Handlers addEventListener attachEvent Detect Case Pass Argument
Snippet: Identification Number »   Snippet: Inclusion syntax »
Monday July 9, 2007 - 06:15:47
Visitors: 10,461 Daily average: 11 Characters (in origin): 4,615
Tagged by its author as: Programming Javascript
permalink Cast your vote for this topic? click here
OBJECTIVE: attach events to a DOM node (layer, tag) detecting what syntax to use and regardless of whether the event name is passed with the prefix on or not.  
 
A simple task.  
function addevent(element, event, func){
if(typeof func=="string"){func=window[func];};
if(typeof element=="string"){element=document.getElementById(element);};
if(!element || typeof event!="string" || typeof func!="function"){return false;};
event=event.toLowerCase();
if(typeof element['addEventListener']!="undefined"){
	if(event.indexOf('on')>-1){event=event.replace(/^on/, '');};
element.addEventListener(event, func, false);
return true;
}
else if(typeof element['attachEvent']!="undefined"){
	if(event.indexOf('on')!=0){event='on'+event;};
element.attachEvent(event, func);
return true;
}
else{
	if(event.indexOf('on')!=0){event='on'+event;};
element[event]=func;
};
return false;
/*keep this comment to reuse freely:
http://www.fullposter.com/?1 */}
INPUTS: first either an already grabbed DOM node (such as, for instance, by getElementById) or a string: in the latter case it is presumed it represents a valid id assigned to a layer.  
 
Then the event as a string: it can either start with 'on' or not, the function will work out the rest (instance, both "onclick" or "click" would work).  
 
Then the function to attach, either as the string name of the function (exclusive of brackets) or as the function object itself (also anonymous functions would do).  
 
RETURNS: boolean false in case of wrong inputs or failure, or boolean true.  
 
CAVEATS: if neither the addEventListener or the attachEvent javascript built in methods are detected as available, the function to be assigned is assigned without using them: in this case this implies that, if any other event handler for that event had already been previously assigned to that element, it will be overwritten by the new assigned one.  
 
Beware, if either addEventListener or attachEvent are available, each subsequent assignment will assign the task again to the element. OBJECTIVE: attach events to a DOM node (layer, tag) detecting what syntax to use and regardless of whether the event name is passed with the prefix on or not, and pass arguments to the attached functions.  
function addevent2(element, event, func, argumentsArray){/*presumes func uses javascript closures*/
if(typeof func=="string"){func=window[func];};
if(typeof element=="string"){element=document.getElementById(element);};
if(!element || typeof event!="string" || typeof func!="function"){return false;};
event=event.toLowerCase();
if(typeof element['addEventListener']!="undefined"){
	if(event.indexOf('on')>-1){event=event.replace(/^on/, '');};
element.addEventListener(event, func(argumentsArray), false);
return true;
}
else if(typeof element['attachEvent']!="undefined"){
	if(event.indexOf('on')!=0){event='on'+event;};
element.attachEvent(event, func(argumentsArray));
return true;
}
else{
	if(event.indexOf('on')!=0){event='on'+event;};
element[event]=func(argumentsArray);
};
return false;
/*keep this comment to reuse freely:
http://www.fullposter.com/?1 */}
INPUTS: as above, plus another input argument which must be an array whose each item represents one of the arguments to pass to the newly assigned event handler function.  
 
RETURNS: as above.  
 
CAVEATS: as above.  
Then, your event handler function to be assigned must use javascript closures. So your event handler function must have this structure, whereas foofunc1 and myargs are placeholder names for whatever other names you may prefer to use:  
function foofunc1(myargs){
return function(/*NO args here*/){
	/*your code goes HERE; the argument named myargs is available in here too and can be called from within this area.*/
}
}
 
Instance:  
<div id="foofoo" style="border:#000000 1px solid;">Hallo World</div>

<script>
function foofunc1(myargs){
return function(/*NO args here*/){
	var element=document.getElementById(myargs[0]);
	var aValue=myargs[1];
	element.style.cssText=element.style.cssText+';'+aValue;
}
}

addevent2('foofoo', 'click', foofunc1, ['foofoo', 'border-color:#ff0000;'])

</script>

Click on Hallo world above now. Its border will become red.
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss
Cast your vote for this topic To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Other topics
This subscriber has a blog too: Read the blog. Shoutbox: 79
Visitors: 10,461
Daily average: 11
Overall visits to all the topics: 1,365,598
Daily average (Calculated from the website subscription day): 1,100.40
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Javascript
Current order: normal
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(1), Books(224), Critical Reviews and Essays(5), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(1), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Programming(3), Programming Ajax(1), Programming Javascript(63), Programming Php(46), Quotes(1), Religion Esoterica and Spirituality(9), Scientifical Reviews(4), Self Improvement(1), Tarots(1)
Showing topics: 1, 20
Available total: 389
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
Php: Get Value Of Specific Html Meta Tag Identification Number: 389 Thursday September 24, 2009 - 14:00:09 Visitors: 1,604 Php Given Url Fetch Youtube Video Codes Embed/Include Video In Other Webpage Identification Number: 388 Saturday September 19, 2009 - 02:03:02 Visitors: 1,673 Php Find Length Of Texts Or Longest Within Instances Of A Given Html Tag Type Identification Number: 387 Saturday September 19, 2009 - 00:24:26 Visitors: 1,517 Riflessioni Sulla Morte Di Carlotta Fondelli Identification Number: 386 Thursday July 30, 2009 - 15:29:52 Visitors: 2,516 Henri Poincaré: Mathematical Creation Identification Number: 385 Tuesday June 16, 2009 - 01:05:38 Visitors: 2,047 Pubblicita' Per Me Stesso: Risposte Pertinenti A Quiz E Domande Impertinenti Identification Number: 384 Friday May 29, 2009 - 01:49:26 Visitors: 2,124 A Collection Of Brief And Famous Or Wise Quotations Identification Number: 383 Monday May 11, 2009 - 06:09:06 Visitors: 2,489 Bertrand Russell: A Free Man's Worship Identification Number: 382 Tuesday May 5, 2009 - 08:41:14 Visitors: 2,499 Protocolli Del Soccorritore? Alla Lettera Please, E Con Il Concorso Di Tutti. Identification Number: 381 Wednesday April 29, 2009 - 20:09:35 Visitors: 2,717 Entropy Revised - At A Glance Identification Number: 380 Wednesday April 29, 2009 - 20:07:08 Visitors: 2,432 Everyday's De Profundis Identification Number: 379 Tuesday April 28, 2009 - 00:10:09 Visitors: 2,582 Javascript Invert Checkbox Status: Uncheck Checked, Check Unchecked. Identification Number: 378 Sunday April 5, 2009 - 12:46:38 Visitors: 3,212 Isaac Newton: Observations upon the Prophecies: Of the Prophetic Language Identification Number: 377 Saturday March 21, 2009 - 23:12:43 Visitors: 2,501 L' Unica Cosa Che Conta E' Lo Yoga Identification Number: 376 Sunday March 15, 2009 - 09:03:00 Visitors: 2,955 Linee Guida Universali Per Operatori Angelici Consegnanti Messaggi Identification Number: 375 Friday March 13, 2009 - 00:15:35 Visitors: 3,002 Ernest Hemingway: Three Shots. Identification Number: 374 Sunday March 1, 2009 - 23:38:24 Visitors: 3,580 Thomas Mann: The Infant Prodigy Identification Number: 373 Saturday February 28, 2009 - 23:17:23 Visitors: 3,149 H.P. Lovecraft: Polaris Identification Number: 372 Wednesday February 11, 2009 - 09:41:59 Visitors: 2,761 Irwin Shaw: Peter Two Identification Number: 371 Saturday February 7, 2009 - 09:41:24 Visitors: 2,904 PHP: Match Each Array Item Once With All The Other Array Items Identification Number: 370 Friday February 6, 2009 - 22:21:15 Visitors: 3,006
««« Previous Next »»»
External services
This page of this subscriber uses external services: Hide
X
X
Visitors: 615,664
You like my work? I have a wish list.
web stats
search profiles Join Update poster
Discussion groups Blog Snippets Polls
Favourite web sites Events Chat Statistics
frequently asked questions Manuals Terms Of Service Contact Full Poster
Applications Free Area Shoutbox
Copyright © Full Poster - 2006, 2010 - All rights reserved