我使用jQuery編寫了一些javascript,以便在我的asp.net頁面中點擊img時觸發。onclick事件不會在firefox或chrome中觸發
的IMG聲明如下:
<img id="zoomIn" alt="Zoom In" src="/Images/Plus.png" onclick="zoomIn();" />
而且.js文件的功能是:
function zoomIn() {
zoomLevel += 1;
showMapImage();
}
function showMapImage() {
//show the location map
var img_url = "http://maps.google.com/maps/api/staticmap?center=" + $asp("lblCoordinates").html() + "&size=200x150&sensor=false&zoom=" + zoomLevel + "&markers=color:green%7C" + $asp("lblCoordinates").html();
$("#imgMap").attr('src', img_url);
}
function $asp(serverID) {
return $("[id$='" + serverID + "']");
}
能正常工作,在IE瀏覽器,但無法在Chrome或Firefox這讓我覺得有一些簡單的錯誤,我無法辨認的地方
你想在zoomIn()函數把剛纔alert(「it works」);並註釋其他行肯定... – dllhell