Hello, this is the first time I use HTML5 build and I don’t know how to add external link? I want to redirect players to another website if they click a button. I found only this example:
function visitWebsite(event) if ( event.phase == "ended" ) then system.openURL( "http://example.com" ) end buttonGames:addEventListener("touch", visitWebsite);
Now, if I test the game in simulator and I click the button, it redirects me to the website.
But if I test it in browsers, it’s blocked by popup blockers. I tried Chrome, FIrefox and Opera.
This sounds like an opportunity to create a JS based plugin. You just need to create an extra .lua file and a .js file in your project and write your JS based function. You might want to look over these two docs:
In this case I don’t think a plugin will help. Most browsers default to blocking JavaScript initiated popup windows. The user must specifically choose to allow a window to be opened via JS.
Yes, that works because the user is initiating the action by clicking the button.
Corona HTML5 is based on WebGL, so you are not actually clicking a DOM based button. Instead a JavaScript action is being called by the compiled Corona HTML5 app, this will result in a blocking of the new window by most major browsers by default.
The only work-around I can suggest is using the modal plugin and open your window from a button in that content since that is a true DOM based button outside of the WebGL context.
I don’t know how Corona HTML5 works, but my games use WebGL and I have no problems. If I use “modal” I can open links in a new tab, and I use images instead of <button>. It works, but I cannot scale this new html content, it does not fit the game.
This sounds like an opportunity to create a JS based plugin. You just need to create an extra .lua file and a .js file in your project and write your JS based function. You might want to look over these two docs:
In this case I don’t think a plugin will help. Most browsers default to blocking JavaScript initiated popup windows. The user must specifically choose to allow a window to be opened via JS.
Yes, that works because the user is initiating the action by clicking the button.
Corona HTML5 is based on WebGL, so you are not actually clicking a DOM based button. Instead a JavaScript action is being called by the compiled Corona HTML5 app, this will result in a blocking of the new window by most major browsers by default.
The only work-around I can suggest is using the modal plugin and open your window from a button in that content since that is a true DOM based button outside of the WebGL context.
I don’t know how Corona HTML5 works, but my games use WebGL and I have no problems. If I use “modal” I can open links in a new tab, and I use images instead of <button>. It works, but I cannot scale this new html content, it does not fit the game.