I want to have a bookmarklet retrieve data from an external XML file. I thought that I could download it as a script tag (kind of like described here ) and then traverse the innerHTML
of the script tag using normal DOM methods. but when I get the script
fonts = document.createElement("script");
fonts.src = "http://www.myExternal/resource/fonts.xml";
fonts.id = "fontXML";
console.log(fonts.innerHTML) //"" (nothing)
I don't get any innerHTML. Is there anyway I can use this strategy (or anything else) to do what I'm trying to accomplish?
Browsers do not allow script content to be browsed like that. So basically you are facing the standard CORS problem.
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.