Jump to content

External link using CocoonJS


doyouknowyou
 Share

Recommended Posts

I'm trying to create a button to link to an external website using Phaser and CocoonJS: 

 
function rate(){    if (navigator.userAgent.match( /iPad/i ) || navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPod/i )){        window.open("http://www.apple.com");    } else if (navigator.userAgent.match( /Android/i) ){        window.open("http://www.google.com");    }}

 

It works fine in the browser, but when compiled with Cocoon nothing happens! Any help would be greatly appreciated!

Link to comment
Share on other sites

Just found out the answer! For those of you that want to know...

 

Make sure to include the Cocoon API found here:   https://github.com/ludei/cocoonjs-plugins

 

Then...

 

function rate(){    if (navigator.userAgent.match( /iPad/i ) || navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPod/i )){        Cocoon.App.openURL('http://www.apple.com');    } else if (navigator.userAgent.match( /Android/i) ){        Cocoon.App.openURL('http://www.google.com');    }}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...