Archive for the ‘Javascript’ Category

Detect IE 5 or higher

I used this code to alert user to use IE 5 or higher to browse the website.

In the HTML head:
<script type=”text/javascript” language=”JavaScript”>
function detectBrowser()
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ((browser!=”Microsoft Internet Explorer” ) || (version<4))
alert(“Please use Internet Explorer to continue”);

In the HTML body:
<body onload=”detectBrowser()”>

Javascript alert box and confirmation box in ASP.NET

In HTML, the code will be:

<input type="submit" name="ButtonNote" value="Note" id="ButtonNote"
onclick="alert('Alert message appears in here.');" />

<input type="submit" name="ButtonDelete" value="Delete" id="ButtonDelete"
onclick="return confirm('Are you sure you want to delete?');" />

In ASP.NET, the VB code to accomplish the same thing will be:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
   If (Not Page.IsPostBack) Then
      Me.ButtonNote.Attributes.Add("onclick", _
      "alert('Alert message appears in here.');")
      Me.ButtonDelete.Attributes.Add("onclick", _
      "return confirm('Are you sure you want to delete?');")
   End If
End Sub