IE web browser control res:// usage - windows

I'm using the IWebBrowser2 control in my app and I have various html files that are stored as resources in the exe. To load these up I use the "res://" protocol. The problem is that with certain versions of IE the pages no longer load up, and instead just shows "Action Canceled, Internet Explorer was unable to link to the page requested."
The pages are referenced in the .rc script like so:
stats.html HTML DISCARDABLE "res\stats.html"
The res request looks like
res://C:\path\To\MyApp.exe/stats.html
This used to work just fine, at some point this behavior changed, presumably with a hot fix or something like that. Now, on my machine, it doesn't work. I have tried altering the res path to look like:
res://MyApp.exe/stats.html
that didn't work.
I then tried changing the rc script:
stats HTML DISCARDABLE "res\stats.html"
and the res path:
res://MyApp.exe/stats
Now it works! However this is really annoying to have to use this way (removing the "." and file extension from the resource name). Does anyone know if this is a bug? A feature? Why does this happen and is there another way around this?
Edit:
After playing around some more I found this to work:
stats.htm HTML DISCARDABLE "res\stats.html"
res://MyApp.exe/stats.htm
changing the ".html" extension in the resource name to ".htm" works but I have no idea why!

Make sure the Content Type is set correctly. Make sure that HKEY_CLASSES_ROOT.html has it's Content Type set to "text/html", otherwise strange things happen. Ditto for .htm as well.

Related

Changing Where CKEditor Looks for Images

I am wondering if there is some way to change where CKEditor looks for images. Right now it uses the location of the web page containing the editor as the root directory but I would like to write a javascript function that can change this directory to any arbitrary path passed to the function.
The bigger picture for this is that I'd like to extend the functionality of CKEditor to be able to save the source it creates to whatever location is picked by the user. I've already implemented getting the source and saving it using wxWidgets but am having trouble getting CKEditor to change its working directory so that images can be included from the directory the user picks.
I've tried using some of the properties like baseDir, basePath, and baseHref to make this possible but as far as I can tell none of them quite do what I'm looking for.
So the process would be:
(1) The user picks a directory where the source will be saved
(2) The user creates a page using CKEditor where images from the directory chosen can be included AND DISPLAYED in CKEditor
(3) The user saves the source of their page to the chosen directory (the source saved here should use the relative path to the images because the source is now located in the same directory as the images it includes)
I realize this is a rather unconventional use of CKEditor but if someone might be able to kick me in the right direction to making this happen, I'd really appreciate it.
EDIT:
So after a little experimenting and changing some backslashes to regular slashes, it looks like the baseHref attribute does what I'd like. I've still not been able to change its value at runtime though as I would like. Does anybody know if this is possible with CKEditor? I'd still like to have a javascript function that I can pass a path to and have it change this baseHref value. Right now I have set its value in config.js.
If this isn't possible, I know you can read and write the source in and out of the editor. So I would like to resort to reading and storing the source from the editor, reloading CKEditor with a new config.baseHref, and then writing the source back into the editor. Does anyone know if the CKEditor api provides functionality to reload its configuration?
Thanks.
I don't expect too many people will be trying to do what I was doing here since CKEditor is usually hosted on a server somewhere, but in case someone finds it helpful, here's what I ended up doing.
As I mentioned in the edit to my question, modifying the baseHref gave me the functionality of prepending the image filename with the directory path leading to it. I wasn't able to find a way to modify it while the editor was running so I ended up telling CKEditor to load an external configuration file each time it started with the line
config.customConfig = 'C:/Users/kenwood/Desktop/MarkCreator2/ckeditor/custom_config.js';
Then I used C++ to write new contents to custom_config.js any time I wanted to switch directories.
Unfortunately this method meant I had to read the contents out of the editor, refresh the page, and then write the editor contents back in any time I wanted to change directories. This was adequate for what I needed though.

Hack Firefox to open extensions with address bar

I see this one time, and know that it not so hard, but can't find any solutions in internet.
Let say I have plugin, as you know it written by XUL. XUL like HTML has tags, js and etc. So I want to debug it with Firebug.
But in default plugin view firebug (as all other plugins disabled). So i need to open my plugin like Web page.
I remember that it's something like
chrome://address/to/my/plugin/page.xul
Does anyone face this problem?
There is no general rule by which you can build the addresses of extension pages. You have to open the extension's XPI file (it's a regular ZIP file, rename it if necessary) and have a look at chrome.manifest inside. E.g. in Firebug's chrome.manifest it says:
content firebug content/firebug/
Which means that the files in the content/firebug/ directory of the extension are accessible under chrome://firebug/content/. You can try opening them as web pages but they won't necessarily work.
A better approach would be using tools that are actually meant for extensions. For example Chromebug or DOM Inspector.

Silverlight: Image Source with no file extension doesn`t display

In my Silverlight project, images for which the source URI does not contain the file extension don`t display, although the documentation says it should.
I set the image source like so:
imgCompanyLogo.Source = new BitmapImage(new Uri(Application.Current.Host.Source, "/Files/" + logoName));
Now, if "logoName" contains the file extension (like ".png" for example), the image is displayed fine, but it simply doesn't if the file is stored without an extension.
This seems to contradict the documentation here which states:
"The format-specific filename extensions such as .png are not necessarily required to be in the URI naming, but if the retrieved file is not determined to be a valid image format, a runtime exception is thrown."
I'm not getting any runtime exception either.
Is this a known issue or am I missing something simple?
Thanks!
PS: Just a little twist, the images display fine while debugging, not when the system is deployed...
I've made some test and the problem seems to be due to the response from the server.
If you try using .png within your project with a Build Action sets to Resource, both images will load regardless the extension.
Now if you try with images hosted on a server, it won't have the same behavior. Actually, if you try to browse the link to an image without extension directly in your browser, it will result in something else. On Chrome it will download the file, and on IE it will display the result as plain text.
That's because of the MIME type. A png should be returned with the type image\png.
There is a trick with .htaccess to set up the MIME-type but you need to have to specify for which extension. It works like this:
AddType image\png yourExtension [Extension2] [Extension3] ..
And if you want to see if why the image didn't load on your Image control, you can add an eventhandler to the ImageFailed event:
<Image Source="..." ImageFailed="Image_ImageFailed" />
But the error message that you will see is not really helpful:
ErrorException = {System.Exception: AG_E_NETWORK_ERROR}

Browser add-on to find a download's origin

Back in the earlier days of the internet I remember that in certain browsers, every time you downloaded an image or a file, the URL of where that file was downloaded from would be written into that file's properties (I guess the summary tab?). I think Netscape v2 did this if I remember correctly.
I really miss that kind of functionality as every once in a while I'll run into a neat little program stored somewhere in the depths of my hard drive and wonder where I got it from originally.
I googled around but I'm not quite sure what terms to use to describe what I'm looking for. So I'm wondering if anyone knows of a Firefox plug-in or something similar that would do this?
If you use the DownThemAll! extension for Firefox, you can tell it to prepend the URL of the site to the downloaded file name...
thus you end up with files like:
download.com_utils_compression_ABCD32.exe
It also works really well when you want to download/queue a bunch of files.
You download http://example.com/foo to ~/Desktop/foo, and you want to see the originating URL in the properties of the local file foo?
Back when I used OS X, I remember Safari used to record the original URL in the resource fork of the downloaded file. Can't remember what the named fork is, well, named, but it'll show up in the properties panel from Finder. Since it's there, Spotlight will probably index it, too, but I haven't used OS X since 10.3.
If you use Opera, and haven't cleared the file out from your download manager, select the download and it'll show the original URL that the file is from in the properties pane.
Is this what you want? If so... well, I don't know of a similar Firefox extension, but it'll clarify the question.
For the IE Browser I use the hell out of Fidler to look at all traffic going across the wire.
For FireFox, you can use the FireBug plugin. There is a "Net" tab that will show you request information that is going across the wire.
Most of the time you can use one of these tools to see what URL was requested in order to start a download. You can also view all the get and post information that might need to be sent in order to have your request succeed.
Fidler is here: http://www.fiddlertool.com/fiddler/
FireBug is here: https://addons.mozilla.org/en-US/firefox/addon/1843
Best of Luck!

Load an image from Firefox cache?

I'm trying to load an image from the Firefox cache as the title suggests. I'm running Ubuntu, so the location of my cache is /home/me/.mozilla/firefox/xxxxxx.default/Cache
However, in the Cache (and this is on Mac, too) the filenames are just ridiculous combinations of letters and numbers. Is there a way to pinpoint a certain file?
You should take a look at the source code of the CacheViewer Add-on.
Download the file instead of installing it (right click and save as) and then extract it (it's just a Zip file, even though it has a .xpi extension), then extract the cacheviewer.jar file inside the resulting chrome folder. Finally go into content and then cacheviewer to find the javascript and XUL files.
From my brief investigation, the useful routines are in the cacheviewer.js file, though if you were hoping there would be a simple javascript one liner for accessing cached items you're probably going to be disappointed. The XUL files (which are just XML) are helpful in working out which JS functions are called to perform particular tasks. I'm not too sure how all this maps into Greasemonkey, rather than the extension environment, but hopefully there's enough code to get you started.
Ummm, that really is an internal implementation detail. But I suggest looking at how about:cache?device=disk and about:cache-entry?client=HTTP&sb=1&key=https://stackoverflow.com/Content/img/wmd/blockquote.png are implemented.
Also, http://www.securityfocus.com/infocus/1832 gives details, too. Note that Firefox doesn't use a separate file for everything...
And of course, Firefox may change the format at any time.
Just give your img src= attribute the full URL. If the image happens to be cacheable (the server sends an appropriate Expires: or Cache-control: header, for example) and it's already in the cache, Firefox will not hit the network.
HTTP caching is supposed to be invisible. When you're generating content, you generally shouldn't worry about it.
You can point REDbot at a URL to see all sorts of delicious information about its cacheability.

Resources