Saturday, October 11, 2008

Java script function to get browser name..

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..............

Saturday, September 27, 2008

Disabling button at client side before firing server side event


If we want to disable the button when clicked until it's execute the server side code then check out this link....

Enjoy...

Firefox 3.0 now supports showModalDialog()


Javascript function window.showModalDialog() is used to create a modal dialog box that displays the specified HTML document. A modal dialog box, is kind of dialog box which retains the focus while open. The user cannot switch back to parent windows until the dialog box is closed.

This works fine in Internet explorer 4.0 and later version of IE but with Firefox 2.0 or below version it was not working. But there is a good news now that Firefox 3.0 supports showModalDialog() function.


Check out this link..


Test this page in Firefox 2 and Firefox 3



Chrome (Google's new browser) also supports showModalDialog().


Enjoy.....
Virendra Dugar
back to top