javascript

  • Rich ajax applications that do not break if javascript is disabled.

    This is a great solution for dealing with checking whether the clients browser has JavaScript enabled/disabled, and then coping with either scenario: Rich ajax applications that do not break if javascript is disabled.

    Know More

  • Cross Browser Support for DOM Events

    Firefox follows the DOM standard and passes an event object to each event listener, however has the global event: windows.event. Problem:I wanted to fire a piece of javascript after the user keyed some text and pressed enter or clicked a button. The skeleton code is below:<input id=”NewsletterEmail” value=”Email here” type=”text”   onfocus=”javascript:this.value = ”;” class=”WiderLoginTextBox” /><input value=”OK”…

    Know More

  • Examples of Regular Expressions

    Trim string in JavaScript var trimre=’^s+|s+$’; // replace whitespacevar trimmedstring = string.replace(trimre,””); Check for a valid date format in JavaScript var re=’^(d{1,2})/(d{1,2})/(d{4})$’; // dd/mm/yyyyif (!datestring.match(re)){ alert(“Date” + datestring + ” not in valid dd/mm/yyyy format”);}else // valid date keyed in{ …valid date keyed} More to follow…

    Know More

  • Insert JavaScript before PostBack Event

    To call some javascript before the postback event is raised, use the following code: if (!Page.ClientScript.IsOnSubmitStatementRegistered(type, “script_onsubmit_editor_” + ClientID)) {   string popTextareaScript =      “var ed = YAHOO.widget.EditorInfo.getEditorById(‘” + editor.ClientID + “‘);”      + “ed.cleanHTML();”;    Page.ClientScript.RegisterOnSubmitStatement(type,       “script_onsubmit_editor_” + ClientID, popTextareaScript); } In the above code example I was trying to populate a textarea from the YUI Editor.

    Know More

  • Debugging JavaScript with Visual Studio.net

    The following piece of advice was taken from a blog (click here to see original) discovered while I was searching for a solution to debugging JavaScript in Visual Studio.NOTE: Currently only works is IE, I have not investigated using Firefox. ASP.Net makes it very easy to write and debug server side code. I’ve found when…

    Know More