How do I use an iframe behind a sprite to create a call button?

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello! I have a small sprite at the bottom of the screen called CallStore. I want to place an iframe behind this sprite with the url directed to an empty html file in the root of my website. Example "CallStore1.html"

    The only element on this page is a hyperlink with Store1's phone number. When the user touches the call button I want them also to touch the hyperlink in the Iframe so the device will open the Call Dialogue on the device with the phone number and ready to call. I assume I need to use the html content property of the iframe but i can't seem to get anything to work. Any suggestions? Thank you!

  • Ive come up with a solution for this. I placed my CallStore Image in the html doc as a hyperlink and then I've sized the iframe accordingly and placed it in front of the button in the layout of the application. Im not sure why but the iframe X and Y coordinates are different than the sprite coordinates that it is in front of. Why is this? This seems like it will be a problem when trying to adjust the layout of the objects in my application for different devices and screen sizes.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Have you tried doing this without the iframe? When sprite button is clicked, do "Browser - Go to URL" or "Browser Open URL in new window". Put the same URL you have in that hyperlink.

    Another option you can try is sending a "fake" click to the hyperlink. Add an ID "myHyperlink" to the hyperlink. Move the iframe off-screen, so it's not visible. On sprite button clicked, add an action "Browser Execute javascript" with code "myHyperlink.click()"

  • Thanks for that nice bit of information dop2000 . I can see where this will be very helpful. Thanks again!

  • Sending the fake click does not work for some reason dop2000 ! Here is my hyperlink <a href="tel:555-555-1212" id="mylink"></a> and I moved the iframe off screen and try to execute javascript through the browser but a call is not initiated on safari or Android.

  • Im using another iframe as well to display my image carousel. This iframe is visible and on screen. dop2000 Is it possible to send fake clicks if the iframe is in view not off screen? Thanks

  • Well, I haven't tried it with iframes. I know this trick works with buttons, check boxes and other form controls. I tried a few examples from this page, but none of them worked for me.

    Do you really need the iframe? You can do image carousel in Construct:

    construct.net/en/tutorials/how-to-create-carousel-animation-in-construct-2-1252

  • I need to get images and data from a database and display them in the application for my business. Can this be done in construct without iframe? It sounds like a huge setback with potential not to succeed as its probably far complicated to do these things through Construct, however Im all ears. So do I just load my php and html page into construct as a file and then call from it there maybe dop2000 ?

  • It should be possible, you can request data with AJAX from your server, load images into sprites etc. But you are probably right, this may now worth the effort since you already have everything working in iframe.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)