开发者

Microsoft JScript runtime error: 'initMap' is undefined

开发者 https://www.devze.com 2023-03-10 13:43 出处:网络
visual studio pops up a notification saying \"Microsoft JScript runtime error: \'initMap\' is undefined\" and points to the line below that contains \"initMap();\".

visual studio pops up a notification saying "Microsoft JScript runtime error: 'initMap' is undefined" and points to the line below that contains "initMap();".

Notice, i've included a reference to the javascript file i'm using in the aspx page.

Error at: (this is from Default.aspx [dynamic] when debugging)

<script type="text/javascript">
//<![CDATA[
initMap();Sys.Application.add_init(function() {
$create(Sys.UI._Timer, {"enabled":true,"interval":4000,"uniqueID":"Timer1"}, null, 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?s开发者_JS百科ensor=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>

My defaultPage.js file contains the following:

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消