本文介绍了.js文件仅在html作为文件打开时才起作用,而在服务器上则不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在线搜索了几个小时,没有解决办法.仅当在浏览器中而不是在localhost上将html作为文件打开html时,以下HTML中显示的.js文件才起作用.我已经尝试过"./subdirectory/file.js
","/subdirectory/file.js
"和"subdirectory/file.js
".以文件形式打开时,所有表格都可以正常工作.
我已经在LAMP和AMPP上尝试了开发站点,结果相同.
目录结构
I have searched online for several hours with no solution. The .js files shown in the HTML below work only when the html is opened as a file in the browser and not on localhost. I have tried "./subdirectory/file.js
", "/subdirectory/file.js
", and "subdirectory/file.js
". All forms work fine when opened as a file.
I have tried my developement site on both LAMP and AMPPs with the same results.
Directory structure
wwwroot
index.html
js/
css/
<link rel="stylesheet" href="./css/style.css" type="text/css" media="all"/>
<link rel="stylesheet" href="./css/jquery-ui-1.8.16.custom.css" type="text/css" media="all" />
<script src="./js/libs/modernizr-2.0.min.js"></script>
<script src="./js/libs/respond.min.js"></script>
<!-- Script for external links in new window -->
<script type="text/javascript" src="./js/external.js"></script>
<!-- Scripts for tab panel -->
<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="./js/jquery-ui-1.8.16.custom.min.js"></script>
推荐答案
<script type="text/javascript">
// Use jQuery via
这篇关于.js文件仅在html作为文件打开时才起作用,而在服务器上则不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!