Jump to content

External link using CocoonJS


Go to solution Solved by doyouknowyou,

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 post
Share on other sites
  • Solution

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...