Skip to content

Instantly share code, notes, and snippets.

@mala
Created July 9, 2011 14:20
Show Gist options
  • Save mala/1073612 to your computer and use it in GitHub Desktop.
Save mala/1073612 to your computer and use it in GitHub Desktop.
jQuery MobileのloadPageで異なるホストを弾く
// jQuery MobileのloadPageで異なるホストを弾く
// Note: 同一ドメインにオープンリダイレクタがないか確認すること
(function($){
var old = $.mobile.loadPage;
var gethost = function(url){
var a = document.createElement("a");
a.href = url;
return a.host
};
$.mobile.loadPage = function(url, options){
if (location.host != gethost(url)){
var deferred = $.Deferred();
deferred.reject( url, options );
return deferred.promise();
}
return old.apply(this, arguments);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment