Filed in: Javascript
Home » Javascript
You may have anonymous function that you want to call later in the same method (or to pass this one by parameter and call this one later). To be able to have a reference to this anonymous function, you need to use a variable that will keep a reference to this anonymous function. Later, when you want to use it, you simply need to call it by writing the...
Many people will use Javascript function call directly into the href attribute of the link tag when they want to execute Javascript. This let them execute Javascript without having to have the fallback of having the browser scrolling to the top. The problem with this method, other than having client script into an attribute which is been created for...
Filed in: Javascript, Web
Did you know that you can know the original value written by the server to the client by calling:
var originalName =document.getElementById("txtUserName").defaultValue;
Yes, the Dom contain for every Html element of type HTMLInputElement and HTMLTextAreaElement the possibility to access the original value. This is interesting to know if...
Filed in: Javascript, Web
Let say that you have an exception on the server side and you want to specify this error to the client, what could you do?
The easiest way is to return the error into the return value directly:
public JsonResult Create(MyObject myObject)
{
//AllFine
return Json(new { IsCreated = True, Content = ViewGenerator(myObject));
//Error
return Json(new...
Filed in: ASP.MVC, Javascript
Not long time ago, I had to modify a code which was using a Frameset with Frame.
I had an issue because the code was written for Internet Explorer only and it was accessing the hidden field by using `parent.window.document.myhiddenfield.value`.
My first reflex was to remove the window and use getElementById. Like this:
parent.document.getElementById('myhiddenfield').value
This...
Filed in: Javascript
In Javascript, if you need to have multiple global variable in a script you could finish with something like a chunk of `var`.
var v1;
var v2;
var v3;
var v4;
var v5;
This can cause problem because, maybe someone will need to define a variable with the same name (locally or globally). To reduce this problematic, you can use Javascript object notation...
Filed in: Javascript
Silverlight can interact with the Javascript that reside in the page that this one is hold. We have seen in the Silverlight Communication post that it’s possible with the use of System.Windows.Browser.HtmlPage.Window.Invoke.
Sometime, an exception can be thrown with the title “InvalidOperationException was unhandled by user code”....
Filed in: Javascript, Silverlight