1man


Member since 07/01/2006

Name: Matt Hobbs

Location: London

Website: http://nooshu.com

52 snippets

38004 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 1728 posted 14 years ago by 1man
Simple illustration of structuring your JavaScript and minimising your use of global vars.
0 1744 posted 15 years ago by 1man
An example taken from JavaScript: The good parts showing how to catch an exception.
0 1804 posted 15 years ago by 1man
Adds a class of hasJS to the html element, can be used for CSS styling.
1 1887 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 2346 posted 17 years ago by 1man
Using JSON-P with jQuery. Note the callback.
0 1709 posted 17 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 1733 posted 17 years ago by 1man
Simple list of commands to use within Adobe AIR to help debug an application.
0 1479 posted 17 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 2369 posted 17 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 1795 posted 18 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 1574 posted 18 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 1491 posted 18 years ago by 1man
An example of how to extent the jQuery objects to include our own methods.
0 1834 posted 18 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 1683 posted 18 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 1679 posted 18 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 2079 posted 18 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 1818 posted 18 years ago by 1man
Apologies if I haven't explained this to well, I'm still trying to get my head round closures.
0 1383 posted 18 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 1573 posted 18 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 1659 posted 18 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 2014 posted 18 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 1814 posted 18 years ago by 1man
Basic usage of the in and instanceOf operators.
0 1586 posted 18 years ago by 1man
Very simple drag and resize function.
1 1695 posted 18 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 1657 posted 18 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 1770 posted 18 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 1775 posted 18 years ago by 1man
addEvent function. Can't remember the exact site i got it from. Works well for me.
1 1308 posted 19 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 1345 posted 19 years ago by 1man
Extend a custom object, and a pre-defined object(e.g. string) using .prototype available in JS.
1 1587 posted 19 years ago by 1man
« Prev 1 2