2014-12-02 22 views
0

this stackoverflow例如關閉從PhoneGap的應用程序內啓動Twitter的應用程序..從href啓動函數的正確方法?

我想下面這個鏈接會工作,但它不是這樣的IM即時通訊猜測正確很多啓動功能?

<a onclick="twitterCheck()">Launch Twitter App</a> 

JS的例子:

//Twitter checker 

// If Mac// 

var twitterCheck = function(){ 

appAvailability.check('twitter://', function(availability) { 
    // availability is 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 is 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');}; 
     }); 
    }; 
}; 
+0

[href與onclick中的JavaScript函數]可能的重複(http://stackoverflow.com/questions/1070760/javascript-function-in-href-vs-onclick) – 2014-12-02 10:32:50

+0

我看了一下那個答案,但仍然不能解決 - 我知道如何啓動功能,但我發佈的JS例子看起來不像一個函數即時通訊用來 - 不知道什麼var twitterCheck = function(){意味着什麼?或者如何啓動它? – MarkL 2014-12-02 10:51:16

回答

相關問題