Microsoft JScript运行时错误:\'initMap\'未定义

问题描述

| Visual Studio弹出一个通知,指出“ Microsoft JScript运行时错误:\'initMap \'未定义\”,并指向包含\“ initMap(); \”的一行。 请注意,我在aspx页面中包含了对我正在使用的javascript文件的引用。 错误发生于:(调试时来自Default.aspx [dynamic])
<script type=\"text/javascript\">
//<![CDATA[
initMap();Sys.Application.add_init(function() {
$create(Sys.UI._Timer,{\"enabled\":true,\"interval\":4000,\"uniqueID\":\"Timer1\"},null,$get(\"Timer1\"));
});
//]]>
<
Default.aspx.cs:
    protected void Page_Load(object sender,EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!ClientScript.IsstartupScriptRegistered(\"init\"))
            {
                Page.ClientScript.RegisterStartupScript
                    (this.GetType(),\"init\",\"initMap();\",true);
                //\"<body onload=\"initialize()\"> \"
                //\"initialize();\"
            }
        }
    }
Default.aspx:
<%@ Page Title=\"Home Page\" Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\"
    Inherits=\"MyProject._Default\" %>

<!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>
    <Meta name=\"viewport\" content=\"initial-scale=1.0,user-scalable=no\" />
    <style type=\"text/css\">
    ......[some stuff here]
    </style>
    <title>Home Page</title>
    <script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=true&region=PK\"></script>
    <script type=\"text/javascript\" src=\"defaultPage.js\"></script>
</head>
<body> 
    <form id=\"form1\" name=\"form1\" runat=\"server\">
    ..... [some stuff here]
    </form>
</body>
</html>
我的defaultPage.js文件包含以下内容
var geocoder;
var map;
var initialLocation = new google.maps.LatLng(24.828417,67.038445);
var browserSupportFlag = new Boolean();
var markersArray = [];
images = new Object();
images.length = 99;

function initMap() {
....[some code here]
}

....
[more functions here]
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)