My solution
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
updateAndroidMarketLinks();
// some more core here ...
function updateAndroidMarketLinks()
{
var ua = navigator.userAgent.toLowerCase();
if (0 <= ua.indexOf("android")) {
// we have android
$("a[href^='http://market.android.com/']").each(function() {
this.href = this.href.replace(/^http:\/\/market\.android\.com\//,
"market://");
});
}
}
});
</script>
</head>
<body>
<a href="http://market.android.com/details?id=com.demosten.android.dadict" target="_blank">Download for Android</a>
</body>
</html>
As you can see my solution is based on JavaScript and jQuery. The idea is to search for 'android' sub-string inside browser's UserAgent and if that is the case - replace HTTP URI part with Android Market URI part, inside all links.I believe a JavaScript only version is not hard to do, but I prefer to use jQuery.
1 comment:
Thanks for the programming script. I bookmarked it future references.
IPhone App Development| Android apps developer|
Post a Comment