Last active
April 12, 2025 13:46
-
-
Save nemesisqp/2182f688125f1ae548233c23b60fafc7 to your computer and use it in GitHub Desktop.
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
<body> | |
<a href="https://www.google.com" target="_blank" rel="noopener noreferrer">Open externally _blank</a> | |
</br> | |
</br> | |
</br> | |
</br> | |
<a href="#" onclick="window.open('https://www.google.com', '_system'); return false;">Open in browser</a> | |
</br> | |
</br> | |
</br> | |
</br> | |
<a href="https://www.google.com" onclick="openExternally(this.href); return false;">Open in browser</a> | |
<script> | |
function openExternally(url) { | |
// Try to use intent for Android Chrome | |
if (navigator.userAgent.includes("Android")) { | |
window.location.href = "intent://" + url.replace(/^https?:\/\//, "") + "#Intent;scheme=https;package=com.android.chrome;end"; | |
} | |
// Try to use universal redirect for iOS | |
else if (navigator.userAgent.includes("iPhone") || navigator.userAgent.includes("iPad")) { | |
window.location.href = "https://www.google.com"; // will prompt "Open in Safari" | |
} | |
else { | |
window.open(url, "_blank"); | |
} | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment