Always Error on Jscript Resize() in IE

4/8/2013 12:12:39 AM
Total Posts 50

Always Error on Jscript Resize() in IE

Hello,

I have always problem on adding this resize().

Message: Object doesn't support this property or method
Line: 189
Char: 10
Code: 0
URI: http://localhost:1231/gisassetatb/NewGISKeyAccount_Monitor.aspx

 

 

<script type="text/javascript"  language="jscript">
function resize() {
var map = AspMap.find('<%=map.ClientID%>');
if (map) map.resize();
}

window.addEventListener("resize", resize, true);

window.addEventListener("orientationchange", resize, true);

</script>

 

How to solve this?is there any alternative to make resize() work?

4/8/2013 3:11:11 AM
MVP
Total Posts 323

Re: Always Error on Jscript Resize() in IE

Please submit a support ticket at http://vdstech.com/ccp.aspx and include the entire code (.aspx, .cs.aspx, .vb.aspx) as an attachment.

4/10/2013 12:59:52 PM
Total Posts 50

Re: Always Error on Jscript Resize() in IE

Thanks. I have sent it.

4/11/2013 10:30:14 AM
MVP
Total Posts 323

Re: Always Error on Jscript Resize() in IE

Interner Explorer does not support the addEventListener method, use the attachEvent method instead.

For your reference, below is the code that resizes the map to the size of its parent DIV tag both in IE and other browsers. It also uses a timer to avoid unnesessary resize events (and postbacks). Portions of the code that are requred marked as bold. The underlined code optionally removes scrollbars and helps to resize the map to the entire page.

<html>
<body onload="resizeMap()" style="padding:0px;margin: 0px;overflow:hidden;width:100%;height:100%;">
<form id="Form1" method="post" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server" />        
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div style="position:relative;width:100%;height:100%;overflow:hidden;">
<aspmap:map id="map" runat="server" Width="500px" Height="400px" MapTool="Pan"></aspmap:map>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>    
<script type="text/javascript"  language="javascript">
var resizeTimer = 0;
function resize() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(resizeMap, 400);
}
function resizeMap() {
  var map = AspMap.find('<%=map.ClientID%>');
  if (map) map.resize();
}

if (!window.addEventListener) {
  window.attachEvent("onresize", resize);
  window.attachEvent("onorientationchange", resize);
}
else {
  window.addEventListener("resize", resize, false);
  window.addEventListener("orientationchange", resize, true);
}
</script>
</body>
</html>

4/11/2013 11:12:54 AM
Total Posts 50

Re: Always Error on Jscript Resize() in IE

Thanks. Very Usefull. It is work.

Now I got the different with this resize(). More Faster than before when resize.

4/11/2013 11:28:44 AM
Total Posts 50

Re: Always Error on Jscript Resize() in IE

Just for note:

Scrollbar was removed. But in IE and Mozilla, Mouse scroll not worked.

And In Mozilla, Arrow down keyboard worked to scrolling page to top. but in IE arrow down key not worked.