DexCurl
DexCurl

Reputation: 1703

The relativity of "<script src="

So on a HTML page, 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'

Upvotes: 0

Views: 171

Answers (3)

Dexter
Dexter

Reputation: 1178

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

Upvotes: 0

Qarib Haider
Qarib Haider

Reputation: 4906

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

Upvotes: 0

Andy E
Andy E

Reputation: 344713

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

Upvotes: 3

Related Questions