Reputation: 1649
here is my code
<script src="admin/js/jquery-1.9.1.js" type="text/javascript"></script>
<link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jQuery-ui-1.10.3.js" type="text/javascript"></script>
<script type="text/javascript">
function pageLoad() {
alert('asdf');
}
</script>
<body>
</body>
when i left blank the body tag alert does not show up. I don't get it how to deal with it. Am i doing any thing wrong? any suggestion will be appreciated.
Update
1) this page is not working
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="admin/js/jquery-1.9.1.js" type="text/javascript"></script>
<link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jQuery-ui-1.10.3.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
alert('asdf');
});
</script>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
2) this page is working, i realize that this page contains script manager if i delete from this page , page will not work . why?
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="admin/js/jquery-1.9.1.js" type="text/javascript"></script>
<link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jQuery-ui-1.10.3.js" type="text/javascript"></script>
<script type="text/javascript">
function pageLoad() {
alert('asdf');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="240">
<tr>
<td height="10">
<asp:ScriptManager ID="SMHome" runat="server" ScriptMode="Release">
</asp:ScriptManager>
</td>
</tr>
</table>
</form>
</body>
</html>
Upvotes: 0
Views: 2684
Reputation: 275799
You need to call the function on your load event. the following will work:
<body onload='pageLoad()'>
Alternatively you can let jquery handle the event for you, as Justin has already posted, i.e:
<script type="text/javascript">
$(function(){
alert('asdf');
});
</script>
Upvotes: 1
Reputation: 245409
You don't call or wire your function to handle any events. jQuery has a very easy built-in way of calling code once the page is ready:
$(function(){
alert('asdf');
});
Upvotes: 0