Skip to content

Instantly share code, notes, and snippets.

@michaelvillar
Created February 1, 2010 23:21
Show Gist options
  • Save michaelvillar/292165 to your computer and use it in GitHub Desktop.
Save michaelvillar/292165 to your computer and use it in GitHub Desktop.
diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j
index 38ddfb5..85fd246 100644
--- a/AppKit/CPWebView.j
+++ b/AppKit/CPWebView.j
@@ -114,6 +114,9 @@ CPWebViewScrollNative = 2;
[self setDrawsBackground:YES];
_loadCallback = function() {
+ if(_html != nil)
+ [self _load];
+
// HACK: this block handles the case where we don't know about loads initiated by the user clicking a link
if (!_ignoreLoadStart)
{
@@ -291,15 +294,21 @@ CPWebViewScrollNative = 2;
else if (_html)
{
// clear the iframe
- _iframe.src = "";
+ if(_iframe.src != "")
+ _iframe.src = "";
// need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document
window.setTimeout(function() {
var win = [self DOMWindow];
-
- win.document.write(_html);
-
- window.setTimeout(_loadCallback, 1);
+ if(win != nil) {
+ // to avoid loop into _loadCallback
+ var tmpHtml = [_html copy];
+ _html = nil;
+
+ win.document.write(tmpHtml);
+
+ window.setTimeout(_loadCallback, 1);
+ }
}, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment