Cordova In-App浏览器打开外部脚本

时间:2016-09-30 05:26:34

标签: angularjs cordova ionic-framework phonegap-plugins inappbrowser

//实际的webscript

<script type="text/javascript">
   var lhnAccountN = "310904-1";
   var lhnButtonN = 38;
   var lhnInviteEnabled = 1;
   var lhnWindowN = 0;
   var lhnDepartmentN = 36316;
   var lhnChatPosition = 'bottomright';
</script>

<a href="http://www.livehelpnow.net/products/live-chat-system" target="_blank" style="font-size:10px;" id="lhnHelp">best live chat</a>

<script src="//www.livehelpnow.net/lhn/widgets/chatbutton/lhnchatbutton-current.min.js" type="text/javascript" id="lhnscript"></script>

//数据存储在会话中。每次连接都丢失。

//所以我使用应用内浏览器在离子移动应用中打开脚本。我无法打开窗户请帮帮我

$rootScope.testChat=function(){
    var options = {
         location: 'no',
         clearcache: 'yes',
         toolbar: 'yes'
     };

      var ref=window.open('http://www.livehelpnow.net/products/live-chat-system', '_blank', options);

        ref.addEventListener('loadstop', function() {
        ref.executeScript({
        code:"var lhnAccountN = '310904-1';var lhnButtonN = 38;var lhnInviteEnabled = 1;var lhnWindowN = 0;var lhnDepartmentN = 36316;var lhnChatPosition = 'bottomright';"
    })
    ref.executeScript({
        code:"var chat; chat.src='www.livehelpnow.net/lhn/widgets/chatbutton/lhnchatbutton-current.min.js' chat.id='lhnscript'"
    })
})
} 
 <a href="http://www.livehelpnow.net/products/live-chat-system" target="_blank" style="font-size:10px;"ng-click="testChat()" id="lhnHelp">best live chat</a>

1 个答案:

答案 0 :(得分:0)

用cordova.InAppBrowser.open()替换window.open()函数。您可以参考https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/index.html了解更多信息。