开发者

How can I load scripts, styles and images from a non-URL source?

I am integrating WebKit (via Qt) into an application. Instead of having WebKit retrieve scripts, CSS files and images via URLs, I want my application to provide them (e.g. retrieved from a database).

For example, a "regular" web page may contain this tag:

<IMG src="photos/album1/123456.jpg">
开发者_开发百科

Instead of WebKit fetching this image from a server or the file system, I would prefer some kind of callback that allows my application to provide this image.

How can I accomplish this?


Maybe this is a bit overkill, but maybe it could work for you.

Simply have your application act as a HTTP server. Then you could have paths like this:

<IMG src="http://localhost:73617/photos/album1/123456.jpg">

Where 73617 is a random port, you can have your application listen on another port. Then, when your app retrieves the request for the image, it fetches it from wherever you want it to. It still involves a a server but at least you have complete control on where you get your resources from.

So, WebKit sees the url in the image, sends a request, your App gets the request, reads the resource, returns the resource. So basically you are still getting it from your App.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜