Microsoft AJAX $addHandler not working in Firefox
Problem: Microsoft AJAX encapsulates DOM and it’s events and provides a browser independent way (apparently not quite there yet) to deal with the DOM and get creative with the DHTML.
The $addHandler method was not working for me in Firefox and after doing some research I found out that the line highlighted below in “Yellow” in the script section fixes the problem for FF.
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Microsoft AJAX $addHandler not working in Firefoxtitle>
head>
<body>
<center>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:ScriptManager>
<div>
<span>Click here:<span>
<input type="button"id="txtNoDigits" />
<div>
<form>
<center>
<body>
<script type="text/javascript">
function pageLoad() {
var txtNoDigits = $get('txtNoDigits');
$addHandler(txtNoDigits, 'click', txtNoDigits_keypress);
}
function pageUnload() {
$removeHandler($get('txtNoDigits'), 'click', txtNoDigits_keypress);
}
function txtNoDigits_keypress(evt) {
evt.preventDefault();
alert('hey');
}
<script>
<html>
Comments
Post a Comment