Creating namespaces for javascript on web applications is a very uncommon approach. However, in a world where the possiblity of clashes between variable and function names is very high, especially among scripts from different sources, it becomes important to understand this neat and elegant concept by Dustin Diaz.Basically the steps that make this possible are as follows:Create the Namespace Object
This script will populate %%B with the usernames held within the 'c:\Documents and Settings' directory. The DO statement deletes all users temporary internet folder contents.FOR /D %%B IN ("c:\Documents and Settings\*") DO del "%%B\Local Settings\Temporary Internet Files\*.*" /s /q /f Unlike the temporary Internet files, there isn't an obvious way to limit the size of
If you create a handler that allows your users to download/view files. When they save the file the browser attempts to save with the filename and extension of the handler.Assuming the name of your handler was "Image.ashx" and in your handler you send an image (maybe resized) to the client. If the user attempts to save that image, it will be saved as "Image.ashx", unless you do one
Create a new variable within the parent function:var me = this;use 'me' in new functionExample: function parentFunction() { this.message = 'Hello World!'; var me = this; var childFunction = function() { alert(me.message); } childFunction(); }
Allows you to call (execute) a method of another object in the context of a different object (the calling object). var result = fun.call(thisArg[, arg1[, arg2[, ...]]]); You can assign a different this object when calling an existing function. this refers to the current object, the calling object. With call, you can write a method once and then inherit it in another object, without having to rewrite
Allows you to apply a method of another object in the context of a different object (the calling object). var result = function.apply(thisArg[, argsArray]);You can assign a different this object when calling an existing function. this refers to the current object, the calling object. With apply, you can write a method once and then inherit it in another object, without having to rewrite the method
Just use: this.Property = value;
At the moment I am researching on how to convert a regular string to HEX and back. You may wonder why? I gues I'll explain later.EDIT:I have come up with some basic yet incomplete functions to achieve this:
I just found out how to modify DOM elements using: element.setAttribute(name, value); Adds a new attribute or changes the value of an existing attribute on the specified element. name is the name of the attribute as a string. value is the desired new value of the attribute. If the specified attribute already exists, then the value of that attribute is changed to the value passed to this function. If it does
not exist, then the attribute is created.
After battling with this for days, I finally figured out how to change the OnClick function for an a HTML anchor tag. This method is compatible with browsers as well as IE.a.onclick = new Function() {}