开发者

The relativity of "<script src="

开发者 https://www.devze.com 2023-02-28 02:58 出处:网络
So on a HTML p开发者_如何学JAVAage, when you link to a JavaScript file, is it the same as it actually being there (like include() in php) or does everything have to be relative to the folder that the

So on a HTML p开发者_如何学JAVAage, when you link to a JavaScript file, is it the same as it actually being there (like include() in php) or does everything have to be relative to the folder that the js file is in?

eg if I have <script src="scriptage/my.js"> </script> in index.html, is a image file to the js file 'image.png' or '../image.png'


JavaScript has no concept of files. Although certain extensions may provide file read/write APIs, everything is relative to the document.


Just like the php include(), it relates to the path of the file where you have attached the script. like here index.html


Your images should be relative to the JavaScript file, not the calling document.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号