georgep Posted May 1, 2018 Report Share Posted May 1, 2018 Wow. Am getting a bit confused. We have a script that where if a field value is NOT blank it displays an icon on the screen. The field contains a URL link to a webpage elsewhere in our app. The icon is just a PNG file (the img scr in script below) which is itself clickable to the web-link URL that is the contents of the field (the field will always contain a URL value - or not). It has functioned fine for a couple of years now Our (old) Script is as follows: <script> if ('[@field:XXXX]' != '') { document.write('<a href="[@field:XXXX]" target="_blank"> <img src="../resources/File_icon_INS.png" alt="Files" height="40" width="40" /></a>'); } </script> We know we need to change it with the new async deploy code and to replace the document.write part with innerHTML. However what we have tried has not worked. Would love it if a kind person could help us out. Thanks :-) Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted May 2, 2018 Report Share Posted May 2, 2018 Hi @georgep, You can try using the following code: <div id="icon"></div> <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if ('[@field:XXXX]' != '') { document.getElementById("icon").innerHTML='<a href="[@field:XXXX]" target="_blank"> <img src="../resources/File_icon_INS.png" alt="Files" height="40" width="40" /></a>'; } }); </script> Hope this helps. Quote Link to comment Share on other sites More sharing options...
georgep Posted May 28, 2018 Author Report Share Posted May 28, 2018 very sorry for late reply. Have been off ill. But have just tested this and it works great. Thank you very much - much appreciated. George 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.