Hi,
Firstly, I’m new to WIX. Old fashioned raw Java, HTML and JavaScript guy here 
However finding it an amazingly easy to use system.
Our application has a mobile app on iPhone and part of the pairing process allows a unique code to be generated in our Wix Website. What I want to be able to do is to click on the code and have it copied to the clipboard so I can easily paste it into the App.
I know how to do this in HTML5 and JavaScript, but is it possible to do in Wix code? Is there a way to call the native JavaScript API to do advanced functionality?
Thanks,
Gary
1 Like
Hey Gary,
Welcome to the Wix Code forums. I think you’ll have fun here.
If you know how to do this in HTML5/Javascript, then you should be able to cobble something together by standing on your head and reaching behind your back. OK - so it’s not quite that bad, just slightly convoluted.
When the user clicks on the code, you can retrieve the value of the code to a variable in the app’s code. Then, pass it by message to a $w.HtmlComponent that contains the code to copy the value to the clipboard. Read the article Working with the HTML Component in Wix Code for details on how to get this done.
All you need to do is to provide the HTML5/Javascript code to copy the unique code from the passed message to the clipboard. Eezy Peezy!
Have fun,
Yisrael
Hi Yisrael,
Yes I have the code and yes looking at this article I should be able to pass it through to the HTML Component using the message API. However the only thing that may block this is that the HTML5 clipboard copy command needs to be executed from a User Interaction such as a link or button click, therefore I have a feeling this may fail. The only thing I may be able to do is render the a button in the HTML code which sits next to the text to copy and on click copies the code (which has already been sent in to it through the message).
Thanks for the info 
Gary
Hey Gary,
Yeah - sorry, didn’t think about the “user interaction” being required.
I agree that you can probably just render in the HtmlComponent itself. With a little CSS you should be able to sufficiently style it so that it matches the theme of your page.
Good luck,
Yisrael
Hello! could I have a code example to do this? I want to add a copy to clippboard to a dynamic page to let the user copy the repeater´s content easily… thanks!
I also would like to have code example as well.
Hi All!
Please note that in this forum we do not provide coding solution rather than giving guidance and pointing to articles and API’s that would help you learn and achieve your goals.
If you feel like you’re struggling with code and can’t make it alone, please visit our WixArena where you can find pro designers and developers to help you build your site.
Doron.