Last active
December 13, 2015 22:49
-
-
Save digitarald/4987578 to your computer and use it in GitHub Desktop.
Open links in new window for apps
This file contains hidden or 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
| 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