2015-01-22 4 views
1

현재 업데이트 패널이 새로 고침 될 때 JavaScript 함수를 호출하려고하지만 어떤 이유로 인해 호출되지 않고 있습니다. 나는 다른 기능을 위해 작동하는 똑같은 방법을 사용하고 있습니다.pageload에서 자바 스크립트 코드가 호출되지 않습니까? .net

C#을,이 페이지로드 이벤트에 있습니다

ScriptManager.RegisterStartupScript(
        UpdatePanel1, 
        this.GetType(), 
        "Modify Map", 
        "modifyMap();", 
        true); 

자바 스크립트 기능 : 누군가가 나를 도울 수 있다면

function modifyMap() { 
      alert(1); 
      //To change the map size if the user is viewing the site on a mobile. 
      if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 
       //Change width/height of map.   

       //Change the width of the wrapper to 100% of the screen. 
       document.getElementById('wrapper-div').style.width = "100%"; 
       //Set the map to fill the wrapper. 
       document.getElementById('canvasMap').style.width = "100%"; 
       //Set the height of the map. 
       document.getElementById('canvasMap').style.height = "500px"; 
      } 

     } 

것은 그 좋은 것입니다.

window.onload = modifyMap; 

함수 안에 넣어하지 마십시오

감사합니다,

캘럼

답변

1

는 등의 onload 이벤트를 추가합니다. 스크립트 종료 태그 바로 전에 항상 넣으십시오. </script>

또한 HTML 태그에 onload 이벤트를 추가 할 수도 있습니다.

<body onload="modifyMap()"> 
1

PreRender에 스크립트를 등록하려고 시도하고 공백없이 키의 이름을 변경해보십시오.

protected void Page_PreRender(object sender, EventArgs e) 
{ 
ScriptManager.RegisterStartupScript(
        UpdatePanel1, 
        this.GetType(), 
        "ModifyMapKey", 
        "modifyMap();", 
        true); 
} 
관련 문제