Start a new topic

Cannot call javascript function from html file loaded by HtmlDrawable

Cannot call javascript function from html file loaded by HtmlDrawable



I have defined html drawable and it loads well. However I cannot get any button or link inside of my html file to trigger an action. Can you advice me what I am doing wrong?

     var htmlLarge = new AR.HtmlDrawable({

                                        html:" "




                                        viewportWidth: 1024,

                                        viewportHeight: 1024,





     htmlLarge.uri = "my.html";


Inside of my.html file I have this html 

function openMyWindow()


 var myUrl ="myCustomUrl://";

 location.href= myUrl;


<input type="button" value="CLICK ME" onClick="javascript:openMyWindow()" style="height:400px; width:400px"/>


myCustomUrl://   - is a custom URL chema that gets caught inside of my iPhone App. Custom URL works. I have tested it... I have also tried defining openMyWindow() function inside of my Architect world. It gets called and works well if I use createWwwButton but I cannot get it triggered from my.html loaded by HtmlDrawable. Can you advise why?: 


}, openMyWindow: function openMyWindowFn(){




Thank you very much!


To react on links inside of your HTML, you also need to set allowDocumentLocationChanges to true. That way, the HTML can also react on any document location changes within the HTML you have defined.

By the way, in your example, you have specified both the uri and html parameter for the HTMLDrawable. When both properties are specified, html takes precedence over uri.



Martin, thank you very much for your response! My script works now!
Login or Signup to post a comment