»
S
I
D
E
B
A
R
«
Passing/calling a function by its name in JavaScript
Sep 14th, 2009 by admin

Today, I needed some code that would allow me to pass a function name as a parameter, and then call that function on the fly. Well, today, I found out something very useful. You can actually pass the function itself into the function, and then use the built in method called apply to call the function.

To help you more easily understand this, I have included an example:

function callMe( useThisFunction, parameter )
{
    useThisFunction.apply( useThisFunction, Array(paramater) );
}

/**************************************************/

function test( outputMe )
{
    alert(outputMe);
}

/**************************************************/

document.onload = function()
{
    callMe( test, ‘Look at me, I have been outed!’ );
};

Enjoy!

Nick

Turning off ‘An error occurred on the server … ’
Sep 14th, 2009 by admin

The full error message actually reads:

An error occurred on the server when processing the URL. Please contact the system administrator

I recently needed a more descriptive error message when debugging a script, and had too much trouble finding the answer I needed. The good news is, if you are reading this, I will tell you how to easily disable the default error message so that IIS will display a much more appropriate error message.

Before I go on, I do want to let you know that this setting should only be set when debugging a script. There are security risks with showing the exact error message to a [malicious] visitor.

  • Open IIS
  • Expand the local computer directory
  • Expand the ‘Web Sites’ directory
  • Right-click the website you are interested in showing detailed errors, select ‘Properties’.
  • Select the ‘Home Directory’ tab across the top
  • Select the ‘Configuration…’ button in the lower-right
  • Select the ‘Debugging’ tab across the top [far right]
  • Under ‘Error messages for script errors’, make sure you have the first radio button selected; ‘Send detailed ASP error messages to client’.

And there you have it. Go back to your browser and hit refresh. Presto!

Nick

»  Substance: WordPress   »  Style: Ahren Ahimsa