简体   繁体   中英

Error Not allowed to load local resource in javaScript

This may be very simple question. I had a list and I customized its icon by using " document.getElementById(list1).style.listStyleImage='url("file:///D:/proj1/pro%20project/images/plus_icon.png")'; " .Here I used a icon which is in D drive to set as list icon. I checked this url and it nicely show the icon in web brawser. But when my web application was run , It shows an error in this line as Not allowed to load local resource: file:///D:/proj1/pro%20project/images/plus_icon.png What is the reason for this issue and can please anyone suggest a way to fix this problem? Thank you.

I found this link which has a similar problem: https://webmasters.stackexchange.com/questions/53870/cannot-load-local-resource

It basically says that because you are using a local path to a file in your webpage, you're stating that the file exists locally to the client and not on your server. The way that it says to fix it is you should store the file in a directory that's served by your web server, and then use a URL to the file that includes your hostname.

Don't use the full path,

Please find the below url for this url("../images/plus_icon.png")

Now it is work please check it

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM