0
我使用的是谷歌網頁來建立一個網站,我遇到了一個我不明白的問題。我在登錄表單上使用window.open來利用谷歌地圖創建一個新窗口。提交按鈕打開一個對話框,詢問我是否要下載或保存文件。我打開並確實按預期顯示了頁面。但該文件是我的C盤上的下載文件。如何消除對話框並讓html代碼自動呈現。這是瀏覽器問題還是編碼問題?有一些我不明白的網絡問題,對於一個經驗豐富的網絡程序員來說,這可能是非常明顯的。我會感謝所有的想法和想法。用window.open打開新的網頁調出對話框
感謝
的window.open代碼如下顯示:
window.open('https://sites.google.com/site/mywebsite/mykmlfiles
/agserver2.htm','_blank');
agserver2.htm如下表所示:
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="MAP" />
<Content type="html">
<![CDATA[
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/HTML; charset=UTF-8">
<title>AgServer</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples
/default.css" rel="stylesheet" type="text/css">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&
libraries=visualization"></script>
<script LANGUAGE="JavaScript" type="text/javascript">
var map;
var layers = [];
function initialize() {
var montana = new google.maps.LatLng(46.0, -110.0);
var myOptions = {
zoom: 11,
center: montana,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
layers[0] = new google.maps.KmlLayer('https://sites.google.com/site/mywebsite
/mykmlfiles/soils.kml', {preserveViewport:true});
layers[0].setMap(map);
}
function togglelayer(i) {
if(layers[i].getMap() === null) {
layers[i].setMap(map);
}
else {
layers[i].setMap(null);
}
</script>
</head>
<body onload="initialize()">
<div id ="toolbar" style="width: 100%; height:20px; text-align:center">
<input type="button" value="Toggle Soils" onclick="togglelayer(0);"></input>
</div>
<div id="map_canvas" style="top:30px;"></div>
</body>
]]>
</Content>
</Module>
聽起來像你需要爲一個文件設置一個MIME類型,所以瀏覽器不會嘗試t o下載它。我只是猜測它是一個KML文件。 –