HTML output flickers in Chrome

Nov 11, 2010 at 11:23 AM

I've only seen this mentioned in a couple of places in search results, so I thought I'd check here if it's a real problem, or an issue with my setup.

I have just tried to use Sandcastle 2.6.1062.1 to generate HTML docs of my project, via SHFB

The documents are compiled fine, and opening the Index.html in Firefox or IE looks great, but in Chrome (7.0.517.44) the page constantly flickers, and the reload/stop button flickers rapidly between it's two states - it seems like the page is constantly reloading itself as fast as it can.

Interestingly, I've just uploaded it to my webserver, and in Chrome both the html and aspx versions look fine.  Looks like an odd quirk of opening the Index.html locally in Chrome.

Dec 6, 2010 at 2:07 PM

I can confirm this occurs, works great in Firefox and flickers in Chrome.

Mar 14, 2011 at 6:23 PM

For anyone who is interested, the problem occurs in Javascript function GetCurrentUrl in SHFB file TOC.js (the original source can be found at %ProgramFiles%\EWSoftware\Sandcastle Help File Builder\Web\TOC.js). When the Index.html page is first loaded, an initialization function calls a function to synchronize the table of contents frame to the content frame. That function calls GetCurrentUrl and GetCurrentUrl attempts to execute this line:


url = window.frames["TopicContent"].document.URL.replace(/\\/g, "/");


Which throws an exception under Google Chrome, because apparently if the document has been loaded from the local file system (i.e., has a file: URL), the document property, following 'window.frames["TopicContent"]' has the value undefined. GetCurrentUrl catches this exception, but unfortunately, its response to the exception is to reload the page. Reloading the page, of course, causes the same sequence of steps to be executed again, ending with the same exception, etc., etc.

I was unable to determine any quick, simple fix for the problem. Apparently, Chrome goes out of its way to prevent Javascript loaded in one frame from determining the URL of another frame if the page was loaded from a file: URL.

A work-around to the problem is to change the line inside the try block in GetCurrentUrl (the line of code shown above) to the following:


        if (window.frames["TopicContent"].document) {
            url = window.frames["TopicContent"].document.URL.replace(/\\/g, "/");

That has the effect of causing GetCurrentUrl to return "", which causes its caller to exit early. The practical effects from the Google Chrome user's point-of-view are:

  1. The Index.html page loads normally and does not flicker.
  2. The SyncTOC icon/button does not work.



Mar 14, 2011 at 6:43 PM

This was fixed in v1.9.2.0 and effectively does what you suggested (returns an empty string).  However, it first shows a message box describing why the problem occurred under Chrome and a workaround (run Chrome with the '--disable-web-security' command line option).