-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