GetMap() works as a button event but not inline. Problem ONLY in IE

A

AAaron123

If I run in Safari or FireFox on my Windows XP it works OK. But in IE7 I get
the mesage that:

IE cannot open the site http://localhost:4272/VEMap/map.aspx

If I comment out the last line of GetMap, IE does not bomb (nor do I get the
map)

With that line not commented out if I comment out:

<script type="text/javascript"> GetMap();</script>

the button btnGetMap works Ok (map displays)

I have the IE developer toolbar and firebug but don't see how they can help!

I think the fact that the button works must be a strong clue but I don't
know how to debug javascript. No breakpoints, right?

You should also know that the Map displays in the page behind the dialog box
announcing the error. As much of the page as I can see looks OK. So why is
IE complaining?



Can you figure this out?







<asp:Content ID="Content2"... this goes into the master body

<div id="VirtualMap" style="position: relative; width: 800px; height:
800px;" >

<input id="btnGetMap" type="button" value="Get Map" name="btnGetMap"
onclick="GetMap();" />

<br />



<script type="text/javascript"> GetMap();</script>

</div>

====

<asp:Content ID="Content1" ...This goes into the master head

<script type="text/javascript">

function GetMap() {

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

}
 
G

Guest

If I run in Safari or FireFox on my Windows XP it works OK. But in IE7 I get
the mesage that:

 IE  cannot open the sitehttp://localhost:4272/VEMap/map.aspx

If I comment out the last line of GetMap, IE does not bomb (nor do I get the
map)

With that line not commented out if I comment out:

<script type="text/javascript"> GetMap();</script>

the button btnGetMap works Ok (map displays)

I have the IE developer toolbar and firebug but don't see how they can help!

I think the fact that the button works must be a strong clue but I don't
know how to debug javascript. No breakpoints, right?

You should also know that the Map displays in the page behind the dialog box
announcing the error. As much of the page as I can see looks OK. So why is
IE complaining?

Can you figure this out?

<asp:Content ID="Content2"... this goes into the master body

<div id="VirtualMap" style="position: relative; width: 800px; height:
800px;" >

<input id="btnGetMap" type="button" value="Get Map" name="btnGetMap"
onclick="GetMap();" />

<br />

<script type="text/javascript"> GetMap();</script>

</div>

====

<asp:Content ID="Content1" ...This goes into the master head

<script type="text/javascript">

function GetMap() {

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

Check if you do not load it multiple times. You can also do it in js

if(map != null)
{
map.Dispose();
}

Hope this helps
 
A

AAaron123

If I run in Safari or FireFox on my Windows XP it works OK. But in IE7 I
get
the mesage that:

IE cannot open the sitehttp://localhost:4272/VEMap/map.aspx

If I comment out the last line of GetMap, IE does not bomb (nor do I get
the
map)

With that line not commented out if I comment out:

<script type="text/javascript"> GetMap();</script>

the button btnGetMap works Ok (map displays)

I have the IE developer toolbar and firebug but don't see how they can
help!

I think the fact that the button works must be a strong clue but I don't
know how to debug javascript. No breakpoints, right?

You should also know that the Map displays in the page behind the dialog
box
announcing the error. As much of the page as I can see looks OK. So why is
IE complaining?

Can you figure this out?

<asp:Content ID="Content2"... this goes into the master body

<div id="VirtualMap" style="position: relative; width: 800px; height:
800px;" >

<input id="btnGetMap" type="button" value="Get Map" name="btnGetMap"
onclick="GetMap();" />

<br />

<script type="text/javascript"> GetMap();</script>

</div>

====

<asp:Content ID="Content1" ...This goes into the master head

<script type="text/javascript">

function GetMap() {

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

Check if you do not load it multiple times. You can also do it in js

if(map != null)
{
map.Dispose();
}

Hope this helps


That did not fix it. Below is what I did.
I wonder if there is something I could put into the alert that might help.

Thanks

function GetMap() {

alert("Check");

if (map != null) {

map.Dispose();

}

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

}
 
G

Guest

Check if you do not load it multiple times. You can also do it in js

if(map != null)
   {
    map.Dispose();
   }

Hope this helps

That did not fix it. Below is what I did.
I wonder if there is something I could put into the alert that might help..

Thanks

function GetMap() {

alert("Check");

if (map != null) {

map.Dispose();

}

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

}

I've tried following

--------------------------------------------------------

<!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>
<title>Virtual Earth Hello World!</title>
<!--A meta tag declaring utf-8 is required.-->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<!--There is a single URL for the Virtual Earth JavaScript.-->
<script type="text/javascript"
src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6">
</script>
<script type="text/javascript">
var map = null;
function GetMap()
{
//The Virtual Earth constructor takes the
//ID of the DIV.
map = new VEMap("myMap");
//LoadMap() creates the map.
//Many optional parameters can be used here.
map.LoadMap();
}
</script>
</head>
<!--You must create the map after the DOM has completely loaded.-->
<body onload="GetMap();">
<!--A simple DIV is needed as the placeholder for the map.-->
<div id="myMap"
style="position:relative; width:400px; height:400px;"></div>
</body>
</html>
 
A

AAaron123

Check if you do not load it multiple times. You can also do it in js

if(map != null)
{
map.Dispose();
}

Hope this helps

That did not fix it. Below is what I did.
I wonder if there is something I could put into the alert that might help.

Thanks

function GetMap() {

alert("Check");

if (map != null) {

map.Dispose();

}

map = new VEMap('VirtualMap');

map.LoadMap(StartPoint, 4, VEMapStyle.Road, false, VEMapMode.Mode2D, true,
4);

}

I've tried following

--------------------------------------------------------

<!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>
<title>Virtual Earth Hello World!</title>
<!--A meta tag declaring utf-8 is required.-->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<!--There is a single URL for the Virtual Earth JavaScript.-->
<script type="text/javascript"
src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6">
</script>
<script type="text/javascript">
var map = null;
function GetMap()
{
//The Virtual Earth constructor takes the
//ID of the DIV.
map = new VEMap("myMap");
//LoadMap() creates the map.
//Many optional parameters can be used here.
map.LoadMap();
}
</script>
</head>
<!--You must create the map after the DOM has completely loaded.-->
<body onload="GetMap();">
<!--A simple DIV is needed as the placeholder for the map.-->
<div id="myMap"
style="position:relative; width:400px; height:400px;"></div>
</body>
</html>

-------------------------------------

It works in my IE7 without any problem. Just copy this code to a
separated file and see if it works. If it works, it means the problem
is somewhere in your code. Hope this helps



I can/t copy it as is because I'm using a master and the context file does
not contain a Body element which may be the root of the problem.

Thanks
 
G

Guest

It works in my IE7 without any problem. Just copy this code to a
separated file and see if it works. If it works, it means the problem
is somewhere in your code. Hope this helps

I can/t copy it as is because I'm using a master and the context file does
not contain a Body element which may be the root of the problem.

Thanks

Well, okay, it seems that's the reason. Either try to put

<script type="text/javascript"> GetMap();</script>

at the end of content page to see if it helps

or

in your masterpage aspx set id tag

<body runat="server" id="Body">

In your content page aspx:

<%@ MasterType virtualPath="MasterPage.master" %>

In your content page codebehind:

HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "GetMap();");

Hope this helps
 
A

AAaron123

It works in my IE7 without any problem. Just copy this code to a
separated file and see if it works. If it works, it means the problem
is somewhere in your code. Hope this helps

I can/t copy it as is because I'm using a master and the context file does
not contain a Body element which may be the root of the problem.

Thanks

Well, okay, it seems that's the reason. Either try to put

<script type="text/javascript"> GetMap();</script>

at the end of content page to see if it helps

or

in your masterpage aspx set id tag

<body runat="server" id="Body">

In your content page aspx:

<%@ MasterType virtualPath="MasterPage.master" %>

In your content page codebehind:

HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "GetMap();");

Hope this helps



I used the second suggestion and it worked great.
Thanks
 
G

Guest

Well, okay, it seems that's the reason. Either try to put

<script type="text/javascript"> GetMap();</script>

at the end of content page to see if it helps

or

in your masterpage aspx set id tag

<body runat="server" id="Body">

In your content page aspx:

<%@ MasterType virtualPath="MasterPage.master" %>

In your content page codebehind:

HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "GetMap();");

Hope this helps

I used the second suggestion and it worked great.
Thanks

Great, glad it's all working now.
Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top