Javascript not working till refresh

Javascript not working till refresh

i have javascript embeded on my jquery mobile page. the problem the javascript doesn't work unless you refresh the page. any solution on how to make this work once the page loads. here's my code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.3.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body,td,th {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    color: #000;
}
</style>
<link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

   $(window).load(function(){
  var url = window.location.search.substring(1);
  $('#mydiv').load('real_news.asp?'+url);
});
     
</script>
<html>
<head>
</head>
<body>
<div data-role="page" id="page">
  <div data-role="header">
    <h1>Header</h1>
  </div>
  <div id="mydiv" data-role="content">Content</div>
</div>
</body>
</html>

</head>

<body>

</body>
</html>