I want to link a php file I have to javascript file. However, my javascript file is saved on my local computer. I learned that I can use URL.createobjectURL('file:///Users/myUser/documents/myJsFile')
to turn the local link into an HTTP link, but the problem is I cannot run that method inside of the src attribute as such.
<script src="URL.createobjectURL('file:///Users/myUser/documents/myJsFile')"></script>
Is there any way I can run javascript inside the attribute?
I suggest you to use a production method: ie setup a real server. If you use php it is likely you already have apache so you could just put myFile.js
inside a public folder and use something like /myJsFile.js
(with / it will use same domain name and port: ideal when going in production.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.