public knowledge blog_load(sender Virendra)

                                                                                                                          Nothing shocks me, I am a Software Engineer.

Posts Tagged ‘JavaScript’

JavaScript Best Pratices

Posted by Virendra Dugar on July 17, 2009

Check this article on Best Pratices of JavaScript.

Enjoy….

Advertisements

Posted in JavaScript | Tagged: | Leave a Comment »

showModalDialog and postbacks in ASP.NET

Posted by Virendra Dugar on March 23, 2009

I learned something new today that when window.showModalDialog is used to open a modal window on the client from parent page using  javascript. And whenever postback occurs in the modal window, it would open up a new window.  A normal window.open works fine, this is the problem only with modal window.

Finally I found a solution which is very simple by just including the below tag in the <head> section of the modal Window.

<base target="_self"/>

 And also we need to set the output cache property to “1” otherwise next time when you try to open the modal window, it will take it from cache.

<% @ OutputCache Duration="1" VaryByParam="none"%>

Enjoy..

Posted in ASP.NET, JavaScript | Tagged: , | 4 Comments »

Java script function to get browser name.

Posted by Virendra Dugar on January 28, 2009

We have this requirement in most of the application to know that which browser user is using to view the web site. We can use javascript to know browser name and this function works with all the broswers…

function GetBrowser()
{
           if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
           { 
                 var ffversion=new Number(RegExp.$1) 
                 if (ffversion>=3)
                  alert(“FF 3.x or above”)
                 else if (ffversion>=2)
                  alert(“FF 2.x”)
                 else if (ffversion>=1)
                  alert(“FF 1.x”)
            }
            else if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent))
            {
                 alert(“Chrome.”);
            }

           else if(/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
            {
                 alert(“Opera”);
            }
            else
            {
             alert(navigator.appName);
            }
             
            return false;
}

 window.onload  = GetBrowser;

Enjoy…………..

Posted in JavaScript | Tagged: | Leave a Comment »

 
%d bloggers like this: