1man


Member since 07/01/2006

Name: Matt Hobbs

Location: London

Website: http://nooshu.com

52 snippets

21296 profile views

0 Comment(s) Posted

View their favorites

Profile

Achievement

first submission:submitting first snipplet popular snippet:having a snipplet with 20 favorites

1man's Recent JavaScript Snippets



« Prev 1 2
Using an object as a simple switch.
0 1234 posted 14 years ago by 1man
Simple illustration of structuring your JavaScript and minimising your use of global vars.
0 1217 posted 14 years ago by 1man
An example taken from JavaScript: The good parts showing how to catch an exception.
0 1179 posted 14 years ago by 1man
Adds a class of hasJS to the html element, can be used for CSS styling.
1 1323 posted 16 years ago by 1man
Click on an input field with a prefilled value, if that value equals the default then select it, if not leave it as it was. Relies on jQuery.
2 1732 posted 16 years ago by 1man
Using JSON-P with jQuery. Note the callback.
0 1175 posted 16 years ago by 1man
I didn't realise until now you could do this in jQuery, very useful. Store a value for later use, then remove it.
4 1139 posted 16 years ago by 1man
Simple list of commands to use within Adobe AIR to help debug an application.
0 910 posted 16 years ago by 1man
Two different ways to open an external link (ones that start in http) in a new window. I know this isn't a great thing to do, but some clients _need_ to have it.
3 1642 posted 16 years ago by 1man
Sometimes i forget to remove firebug console commands when debuging, which makes IE and some other browsers fail / cry. To stop this happening use the below script from firebugx.js on the firebug lite homepage.
3 1042 posted 17 years ago by 1man
I'm sure i can clean this up quite a bit, but it works for the moment. This function looks to see if you are on a selected page. If you are it hides the navigation, then loops through and shows each li one after the other. So they don't all fade i...
0 1029 posted 17 years ago by 1man
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 967 posted 17 years ago by 1man
An example of how to extent the jQuery objects to include our own methods.
0 1228 posted 17 years ago by 1man
If you have a complex function you may need to pass it lots of arguments. Instead of having to remember how many you need to pass, and passing 'null' for un needed arguments, pass the function an object. Now you can set the defaults inside the fun...
0 1157 posted 17 years ago by 1man
Found this quick little bit of code on the Google jQuery discussion group. It simply fades the background image of a link you have hovered over to a certain color, then fades it back to the original color.
4 1144 posted 17 years ago by 1man
Very simple style switcher using jquery. Takes 3 links with id's on each. When one is clicked various styles are removed, then a new one is added.
3 1443 posted 17 years ago by 1man
Adobe Air has a few security settings that stops you executing certain AIR methods when inside the sandbox. The code below bridges between the root document and the security sandbox, allowing you to open a URL in AIR in a default browser.
1 1209 posted 17 years ago by 1man
Apologies if I haven't explained this to well, I'm still trying to get my head round closures.
0 924 posted 17 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 973 posted 17 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 1071 posted 17 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 1166 posted 17 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 1074 posted 17 years ago by 1man
Basic usage of the in and instanceOf operators.
0 1063 posted 17 years ago by 1man
Very simple drag and resize function.
1 1206 posted 17 years ago by 1man
Very basic way to toggle an element to slide in and out using mootools 1.1. Uses FX.Slide, other transitions are available.
2 1142 posted 17 years ago by 1man
Create a simple object and add properties and a method. Note where the object is parsed (not from top to bottom).
2 1027 posted 17 years ago by 1man
For forms with a default value onload you don't want your users to have to select the value, delete it and then insert their own input. This function focuses on a selected input, then it selects the default text so the user can easily type their o...
1 1182 posted 17 years ago by 1man
addEvent function. Can't remember the exact site i got it from. Works well for me.
1 907 posted 18 years ago by 1man
Shows you how to link 2 objects together via the object function. If a value isn't found in the object, it will look for it in the linked object.
0 901 posted 18 years ago by 1man
Extend a custom object, and a pre-defined object(e.g. string) using .prototype available in JS.
1 1037 posted 18 years ago by 1man
« Prev 1 2