Ninjadoodle Posted June 14, 2018 Share Posted June 14, 2018 Hi @enpu I know this is probably a basic question, but how do I open a link in a new window (that will also work on devices)? I can't find the info in the docs. Thanks heaps! Quote Link to comment Share on other sites More sharing options...
enpu Posted June 14, 2018 Share Posted June 14, 2018 @Ninjadoodle try window.open('https://www.panda2.io'); Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 14, 2018 Author Share Posted June 14, 2018 @enpu Nice - thank you! - Only thing is that this only seems to work on desktop browser - not the editor / panda remote or even iOS browser. Quote Link to comment Share on other sites More sharing options...
enpu Posted June 14, 2018 Share Posted June 14, 2018 Mobile browsers usually require that you call window.open on touch event, otherwise it will be blocked. On native app, it might require plugin. Try it on touch event and let me know how it works. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 14, 2018 Author Share Posted June 14, 2018 @enpu Trying this now, but can't seem to find the correct syntax for touch events ( I wish there was a search in the docs lol ). Quote Link to comment Share on other sites More sharing options...
enpu Posted June 14, 2018 Share Posted June 14, 2018 Sorry by touch events i mean interactive functions on Panda, like mousedown: https://www.panda2.io//examples#sprite-interactive https://www.panda2.io//examples#scene-mousedown Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 14, 2018 Author Share Posted June 14, 2018 @enpu Oh ok, sorry I misunderstood. In that case, I'm already doing this ... game.scene.buttonFacebook = new game.Sprite('buttonFacebook.png'); game.scene.buttonFacebook.position.set(416, 736); game.scene.buttonFacebook.anchorCenter(); game.scene.buttonFacebook.interactive = true; game.scene.buttonFacebook.addTo(game.scene.ib); game.scene.buttonFacebook.mousedown = function() { window.open('https://www.panda2.io'); }; Quote Link to comment Share on other sites More sharing options...
enpu Posted June 14, 2018 Share Posted June 14, 2018 @Ninjadoodle Your code sure is correct. Mobile Safari seems to block all pop-ups by default, that can be changed from settings. You can also just change the url with window.location.href = 'https://www.panda2.io'; Though that will change the url of the current browser window, meaning it will completely exit your game. But that code should work anywhere, not just at interactive function. I just fixed window.open to work on the editor, will be on next release. Also need to make changes to Panda Remote so it works there too, and when exporting as native app. Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 14, 2018 Author Share Posted June 14, 2018 @enpu - thanks heaps for the explanation and the options Quote Link to comment Share on other sites More sharing options...
Jorasso Posted June 15, 2018 Share Posted June 15, 2018 Try to open new window from mouseup event, instead of mousedown. It used to work for me on iOS. Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted June 15, 2018 Author Share Posted June 15, 2018 @Jorasso Awesome tip!! I've tried and it works Thanks heaps! Jorasso 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.