Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hezi
Created December 9, 2012 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hezi/4244298 to your computer and use it in GitHub Desktop.
Save hezi/4244298 to your computer and use it in GitHub Desktop.
partial GIPSuperWebViewInit.js
. . .
navigator.googleInternal = {
iframe_: undefined,
isInitialized: false,
init: function() {
if (this.isInitialized) {
return;
}
this.iframe_ = document.createElement('iframe');
var cssText = 'position:absolute;top:-5000px;height:2px;width:2px;';
this.iframe_.style.cssText = cssText;
this.iframe_.src = 'about:blank';
document.body.appendChild(this.iframe_);
this.isInitialized = true;
},
dispatch: function(object, method, opt_args) {
var urlWithoutHash = window.location.href.split('#')[0];
var requestUrl = urlWithoutHash +
'#googleapp/api/' + object + '/' + method +
(opt_args ? '/?' + this.serialize_(opt_args) : '');
var oldHash = window.location.hash;
var newHash = 'googleapp/api/' + object + '/' + method +
(opt_args ? '/?' + this.serialize_(opt_args) : '');
this.init();
this.iframe_.contentWindow.location.hash = newHash;
// Setting the hash to an empty string will cause the page to jump to
// the top of the iframe, which is the top of the window. We instead set
// it to a dummy value to prevent any jumping form occuring.
this.iframe_.contentWindow.location.hash = 'null';
},
. . .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment