Created
July 9, 2011 14:20
-
-
Save mala/1073612 to your computer and use it in GitHub Desktop.
jQuery MobileのloadPageで異なるホストを弾く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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