Created
March 25, 2014 12:13
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Index</title> | |
<!-- Stand-alone settings for iOS. --> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" /> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | |
<!-- Load scripts. --> | |
<script type="text/javascript" src="./jquery-1.7.1.min.js"></script> | |
<script type="text/javascript" src="./links.js"></script> | |
</head> | |
<body> | |
<h1> | |
Hello, Index Here | |
</h1> | |
<p> | |
Go to <a href="./index2.htm">Index 2</a>. | |
</p> | |
</body> | |
</html> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Index 2</title> | |
<!-- Stand-alone settings for iOS. --> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" /> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | |
<!-- Load scripts. --> | |
<script type="text/javascript" src="./jquery-1.7.1.min.js"></script> | |
<script type="text/javascript" src="./links.js"></script> | |
</head> | |
<body> | |
<h1> | |
Hello, Index 2 Here | |
</h1> | |
<p> | |
Go to <a href="./index.htm">Index</a>. | |
</p> | |
</body> | |
</html> |
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
// Listen for ALL links at the top level of the document. For | |
// testing purposes, we're not going to worry about LOCAL vs. | |
// EXTERNAL links - we'll just demonstrate the feature. | |
$( document ).on( | |
"click", | |
"a", | |
function( event ){ | |
// Stop the default behavior of the browser, which | |
// is to change the URL of the page. | |
event.preventDefault(); | |
// Manually change the location of the page to stay in | |
// "Standalone" mode and change the URL at the same time. | |
location.href = $( event.target ).attr( "href" ); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment