Welcome To Snipplr
Everyone's Recent JavaScript Snippets Tagged function
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This snippet allows to know the parent function caller name of any level from the calling function.
1
825
posted 10 years ago by zandor
JavaScript
Template for a Javascript function with optional and mandatory arguments passed as an object collection
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
1359
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
921
posted 12 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
1125
posted 12 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
937
posted 12 years ago by hellowouter
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
989
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
850
posted 13 years ago by alberomo
This snippet lets you call a Javascript function declared within an IFrame from the parent element of the IFrame
0
1614
posted 13 years ago by alexscript
Simple function to return a decimal value between the minValue and the maxValue.
0
1710
posted 14 years ago by Jamie
Simple function to return a value between the minValue and the maxValue.
0
806
posted 14 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
603
posted 15 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
942
posted 15 years ago by segdeha
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
666
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
1012
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
744
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
705
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
740
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
832
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
892
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
849
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
1004
posted 17 years ago by 1man