jquery - Correct way to launch a function from a href? -
following this stackoverflow example off launching twitter app within phonegap app..
i thought link below work not im guessing im lot launching function correctly?
<a onclick="twittercheck()">launch twitter app</a>
js in example:
//twitter checker // if mac// var twittercheck = function(){ appavailability.check('twitter://', function(availability) { // availability either true or false if(availability) { window.open('twitter://user?screen_name=xerxesnoble', '_system', 'location=no');} else{window.open('https://itunes.apple.com/ca/app/twitter/id333903271?mt=8', '_system', 'location=no'); }; }); }; //if android var ua = navigator.useragent.tolowercase(); var isandroid = ua.indexof("android") > -1; //&& ua.indexof("mobile"); if(isandroid) { twittercheck = function(){ appavailability.check('com.twitter.android', function(availability) { // availability either true or false if(availability) {window.open('twitter://user?screen_name=xerxesnoble', '_system', 'location=no');} else{window.open('https://play.google.com/store/apps/details?id=com.twitter.android', '_system', 'location=no');}; }); }; };
please take @ article http://javascript.info/tutorial/functions-declarations-and-expressions. think confused way how function has been declared.
the way how call function tried - functionname()
. if doesn't work, must have reasons.
Comments
Post a Comment