admin管理员组文章数量:1389757
Okay I have a js file in htdocs and when I include it in my php page it doesn't work however when I load it from online it works I don't know what is wrong with it. I have:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".dtd">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> test</title>
</head>
I am putting the js file at the bottom of the page and this doesn't work,
<script type="text/javascript" src=".7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/boostrap.js"></script>
<script type="text/javascript" src="js/wpts_slider_multiple.js"></script>
This works,
<script type="text/javascript" src=".7.2/jquery.min.js"></script>
<script type="text/javascript" src=".js"></script>
<script type="text/javascript" src=".js"></script>
Okay I have a js file in htdocs and when I include it in my php page it doesn't work however when I load it from online it works I don't know what is wrong with it. I have:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> test</title>
</head>
I am putting the js file at the bottom of the page and this doesn't work,
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/boostrap.js"></script>
<script type="text/javascript" src="js/wpts_slider_multiple.js"></script>
This works,
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.jqueryslidershock./wp-content/plugins/tsslider/js/boostrap.js"></script>
<script type="text/javascript" src="http://www.jqueryslidershock./wp-content/plugins/tsslider/js/wpts_slider_multiple.js"></script>
Share
Improve this question
asked Oct 9, 2013 at 5:18
LmxcLmxc
2834 gold badges6 silver badges17 bronze badges
6
- whichever browser your opening , just try checking in the JS/web console for errors.It will tell what exactly your problem is .For chrome its F12 to bring up the console – Mevin Babu Commented Oct 9, 2013 at 5:24
- 1 Check in console and tell us what error you got there – Blu Commented Oct 9, 2013 at 5:27
- @MevinBabu I am using Firefox. – Lmxc Commented Oct 9, 2013 at 5:28
- I see ReferenceError: jQuery is not defined @ localhost/js/cloudzoom.js:5. Basically this is another file I don't know if it has something to do with this prob. – Lmxc Commented Oct 9, 2013 at 5:31
-
1
if you include
JQuery
file it must be above all js files Best place for JQuery file is in head section – Blu Commented Oct 9, 2013 at 5:33
4 Answers
Reset to default 2try this: src="/js/boostrap.js">
instead of src="js/boostrap.js">
the /
is your root path
you can use this absolute path /js/boostrap.js
in php, js, css files, and it works fine.
<script type="text/javascript" src="/js/boostrap.js"></script>
<script type="text/javascript" src="/js/wpts_slider_multiple.js"></script>
You should give full path
of your jquery files
like
http://example./js/boostrap.js
Code
<script src="http://example./js/boostrap.js"></script>
<script src="http://example./js/wpts_slider_multiple.js"></script>
Either of the following is happening.
Incorrect path - Please check the file paths.
No Read permission for the JS files - If you are sure that the path for the local JS files are correct, check their read
permissions.
File does not exist - Simple reason as it states. I believe that it's not the case.
Let me know what you found.
try giving the paths like
<script type="text/javascript" src="/js/boostrap.js"></script>
<script type="text/javascript" src="/js/wpts_slider_multiple.js"></script>
src='/js/boostrap.js'
Assuming your root is http://localhost
then the above link should always resolve to http://localhost/ProjectName/js/boostrap.js
whether it's called from
http://localhost/ProjectName/index.php
or http://localhost/ProjectName/subdir/index.php
Make sure the js files are present within your folder structures
Always try to give relative paths to your files so that they can be easily found.
本文标签: javascriptlocal js file not workingStack Overflow
版权声明:本文标题:javascript - local js file not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744602069a2615127.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论