Skip to content

Instantly share code, notes, and snippets.

@digitarald
Last active December 13, 2015 22:49
Show Gist options
  • Select an option

  • Save digitarald/4987578 to your computer and use it in GitHub Desktop.

Select an option

Save digitarald/4987578 to your computer and use it in GitHub Desktop.
Open links in new window for apps
var selfReq = navigator.mozApps.getSelf();
isMozRuntime = false;
selfReq.onsuccess = function() {
isMozRuntime = selfReq.result;
if (isMozRuntime) {
// Responsive action to mozilla apps runtime (force links in new window
respondToMozRuntime();
}
};
function respondToMozRuntime() {
jQuery(document).on('click', 'a:not([href*="://' +location.host + '"])', function(ev) {
ev.preventDefault();
window.open(this.href);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment