javascript - Location of image resources -
i have plugin runs off customer's websites. plugin @ http://mycompany.com/tool.js, , needs pull in images. problem javascript seems try pull images customer's site, rather own site. here js:
button.style.csstext = 'position:absolute;top:-20px;right:-20px;background-image:url(/resource/button.png);
in above js, the retrieval url customer.com/resource/button.png (the site plugin runs), rather sites mycompany.com/resource/button.png.
note cannot use absolute paths, become pain between environments (test/prod) , because image retrieval must use http/https based on client environment (otherwise can errors if http used on https site).
just replace background-image:url(http://mycompany.com/resource/button.png);
Comments
Post a Comment