-1
我無法在html頁面(本地)中顯示我的.txt
文件,其中.load
。文件與.js
位於同一個文件夾中。無法加載ajax
$(function(){
$("#div1").load("text.txt");
});
我無法在html頁面(本地)中顯示我的.txt
文件,其中.load
。文件與.js
位於同一個文件夾中。無法加載ajax
$(function(){
$("#div1").load("text.txt");
});
我最後一次檢查,打開本地文件與本地HTML將在IE瀏覽器而不是Chrome瀏覽器,Firefox等因安全原因。
如果您對HTML和JavaScript感到滿意,並且想要在本地運行本地文件並操作本地文件,請查看HTML Applications或.hta
。它非常整齊。
這是Microsoft's documentation這裏是an example with Javascript。
爲了避免Windows系統中的ActiveX的警告,你的程序的名.hta封裝,即下運行 ,作爲一個應用程序(如.exe文件)。
下面的代碼在屏幕中橫向和低點位於中心位置 的大小窗口(例如:1030 x 95像素)中打開.hta「傘」, 下的應用程序。它不允許 滾動。使一個文本文件並將其保存YourChoiceOfName.hta
下
<HTML>
<HEAD>
<script language="javascript" type="text/javascript">
function Set(){ // this limits the size of the window opened and positions it
var l=(screen.width/2 - 515); // centre - half the window width
var t=(screen.height-130); // where you want it vertically
self.moveTo(l,t);
self.resizeTo('1030','95'); // as you can see, this example opens a longish but squat window, near the task-bar
}
</script>
<TITLE>BlahBlah-The Progam</TITLE>
<HTA:APPLICATION ID="BlahBlah-App"
BORDER="thin"
INNERBORDER="no"
SCROLL="no"
SCROLLFLAT="no"
CAPTION="yes"
MAXIMIZEBUTTON="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
NAVIGABLE="yes"
ICON="images/favicon.ico"
WINDOWSTATE="normal">
<STYLE> body {margin:0} </STYLE>
</HEAD>
<BODY onload="Set()" >
<IFRAME src="blahblah.htm" application=yes width=1030 // width is that of your window
height=95 marginwidth=0 marginheight=0 /// height is that of your window
frameborder=0>Iframes not supported</IFRAME>
</BODY>
</HTML>
請注意,你不必像他那樣用一個iframe,你可以把你的HTML就在HTA文件。
它和html頁面在同一個文件夾中嗎?這是重要的。 – recursive
你是否用Apache或類似的東西來提供頁面?如果是,請嘗試將js綁定到的html文件的相對路徑放到文件「text.txt」中。 – cezar
這是本地嗎?該文件需要託管在網絡服務器上才能正常工作......它不能在本地機器上 – abc123