Welcome To Snipplr


Everyone's Recent JavaScript Snippets Tagged function



« Prev 1 2
This snippet allows to know the parent function caller name of any level from the calling function.
1 583 posted 9 years ago by zandor
A simple template for a JavaScript function which allows for an arbitrary number of named arguments to be passed in. This is achieved by passing a single object as an argument with each of the 'real' arguments being a key/value pair. In this way argu...
0 1088 posted 11 years ago by davidwaterston
Set the desired date within the function. Make some images and label them "1.jpg, 2.jpg, 3.jpg, etc...". That's how it's done.
1 699 posted 11 years ago by o0110o
Simulate the $_GET array from php in javascript to get url parameters this way: url= http://localhost/?var1=example $_GET['var1'] will return "example" Just copy and paste the code.
2 884 posted 11 years ago by sergiazow
In this purely constructed example, we create anonymous function and use call to invoke it on every object in an array. The main purpose of the anonymous function here is to add a print function to every object, which is able to print the right index...
0 734 posted 11 years ago by hellowouter
This snippet uses jQuery.extend() to merge the objects.
0 521 posted 12 years ago by viskenxp
By not being limited to provide certain arguments/parameters in right order when calling a function, makes the function more versatile and easier to extend without breaking old code (e.g. calls to the function). One solution is to pass an associati...
0 789 posted 12 years ago by coprolit
Description: Execute different functions when the page loads in a better way than default onload JS event. Include it in the end of the JS document. Arguments: Name of the function that you want to execute when the page loads. Author: Simon Williso...
0 613 posted 12 years ago by alberomo
This snippet lets you call a Javascript function declared within an IFrame from the parent element of the IFrame
0 1329 posted 12 years ago by alexscript
Simple function to return a decimal value between the minValue and the maxValue.
0 1381 posted 13 years ago by Jamie
Simple function to return a value between the minValue and the maxValue.
0 608 posted 13 years ago by Jamie
Runtime Object Evaluator; search for string object properties that start with !! and eval the content. Very useful if you want to load JSON from file and evaluate its fields on effective usage or access global variables at runtime. [Follow me on T...
1 452 posted 14 years ago by straps
Assign methods to a Function prototype when you intend to create instances of the type of object. Use object literals when you just need a container for functions.
0 739 posted 14 years ago by segdeha
just testing snipplr.com
0 503 posted 14 years ago by cfleschhut
Get Function Name ============ This will only return (a string) if the object passed to getFunctionName is a function or an "object" function from IE. The function does not rely on function.name if present as it can't always be trusted. Examp...
0 505 posted 15 years ago by Sephr
How to use: 1) < script type="text/javascript" src="path-to-file.js"... 2) < body onload="oHW.preMontar('img1_on.jpg','img2_on.jpg','img3_on.jpg');"... 3) < a href="#" onmouseout="oHW.Restore()" onmouseover="oHW.Cambiar('mnind','img1_on.jpg'...
2 782 posted 16 years ago by hellion
Quick example to show how 'this' depends on how the function in which you called it in was being invoked. From jQuery in Action.
1 552 posted 16 years ago by 1man
Apologies if I haven't explained this to well, I'm still trying to get my head round closures.
0 536 posted 16 years ago by 1man
This method allows you to call a function as a method of another object. The first argument the call method expects is the object it is to operate on. Any others are part of the function. Note how the this keyword now refers to the comp object, so a...
0 563 posted 16 years ago by 1man
The important thing to notice is the () operator in a[2]. It is invoking the function inside a[0] with the argument a[1].
1 635 posted 16 years ago by 1man
Every function has an object called the arguments object. This is an object that contains all the arguments that were passed to the function. The example below shows how to access these. Very rarely used but useful to know. Note: it may look like an...
2 694 posted 16 years ago by 1man
Simple way of allowing functions to take optional arguments. Always place the optional arguments last, so you don't have to explicitly pass an argument as "undefined".
3 629 posted 16 years ago by 1man
Very basic grab a line of text from a file then display it in an alert box. Uses other functions for loading prepareLinks() and creating the request.
2 780 posted 17 years ago by 1man
« Prev 1 2