I'm trying to determine if there is a way to call the GetRoute() method from script that is embedded in the <body> of the page rather than in the <body onload=...> tag. Here are the two simplest map examples I've been able to construct to illustrate this idea. The second version doens't load in IE but works fine in Firefox. I get the following error in IE -
---------------------------
Error
---------------------------
A Runtime Error has occurred.
Do you wish to DebugLine: 1
Error: Unexpected call to method or property access.
---------------------------
Yes No
---------------------------
Can anyone help me understand why this is happening in IE and if there is a workaround. I don't control the whole construction (html is built by JSP that is owned by someone else) and the onload tag may prove to be tricky.
Thanks very much!
Bart
Version 1 (Works in IE and Firefox):
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>GetRoute Error</title>
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
function GetMap(){
map = new VEMap("sl_sr_map");
map.LoadMap();
map.GetRoute( '55419', '55403');
};
</script>
</head>
<body onload="GetMap();">
<div id="sl_sr_map"></div>
</body>
</html>
Version 1 (Doesn't Work in IE but is fine in Firefox):
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>GetRoute Error</title>
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
function GetMap(){
map = new VEMap("sl_sr_map");
map.LoadMap();
map.GetRoute( '55419', '55403');
};
</script>
</head>
<body>
<div id="sl_sr_map"></div>
<script language="javascript" type="text/javascript" defer="true">
GetMap();
</script>
</body>
</html>