问题
I'm embedding a web page in my program using this method:
WebBrowser1.DocumentText = "<b>hello</b> world <img src=""/images/amiga.png"" />"
so the html is in the program, but I would like to load the css and images from an outside place (such as ./themes/default/style.css).
So where do I put the files during development, and what do I makes the paths?
I want the html to be static but allow users to change the css.
edit: actually, since it's in the code, if there's something in vb that puts in the program location, that could work, like %programlocation% + "/themes/default/style.css"
and I'm also looking into using gecko instead of the ie rendering engine, so if anyone knows a good way to do it let me know
回答1:
So you're trying to do this purely from the filesystem, and with no web server? I'm not completely sure if this would work, but you could try doing:
WebBrowser1.DocumentText = "<head><link rel=""StyleSheet"" HREF=""file:///" & Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("\\", "/") & "/themes/default/style.css"" TYPE=""text/css"" /></head><body><b>hello</b> world <img src=""/images/amiga.png"" /></body></html>"
来源:https://stackoverflow.com/questions/12657875/load-external-files-such-as-css-into-webbrowser-control