This is a migrated thread and some comments may be shown as answers.

iframe contentWindow property not working for Google Chrome

1 Answer 1169 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hans-Jürgen
Top achievements
Rank 1
Hans-Jürgen asked on 31 May 2012, 02:48 PM
hi,

in my app I have a radhtmlplaceholder that loads a page containing an applet.
When the page has finished loading and the applet is loaded I can call a javafunction on the applet using
 

HtmlElement

 

 

iframe = simplesearchquerymarvinappletEditable.HtmlPresenter.Children[0] as HtmlElement;

 


iframe.SetAttribute(

 

"id", "myID");

 

HtmlObject

 

 

myhtmlobj = HtmlPage.Document.GetElementById("myID").GetProperty("contentWindow") as HtmlObject;

 



myhtmlobj.Invoke(

 

"MyJavascriptFunction");

 


All that works well on IE (v8+9) and FF (v12), but **NOT** using Google Chrome (v19).

Accoring the Web Google Chrome does not support the contentWindow . Instead (accoring the Web) you need to use the contentDocument property.

Question: How do I call my Javascript function when I obtain my contentDocument object ???
I already tried to call invoke on the contentDocument object but  this (as kind of expected) did not work.

Any help is appreciated.
Best regards
Hans-Juergen




1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 01 Jun 2012, 02:17 PM
Hello Hans,

We managed to reproduce this issue. The following code is OK in IE but it dos not work in Chrome:

private void placecHolder_UrlLoaded(object sender, EventArgs e)
    {
 
        // HtmlDocument requires using System.Windows.Browser.
        holder = ((App.Current.RootVisual as UserControl).Content as Grid).Children[0] as RadHtmlPlaceholder;
 
        HtmlElement iframe = (HtmlElement)holder.HtmlPresenter.Children[0];
 
        HtmlWindow contentWindow = iframe.GetProperty("contentWindow") as HtmlWindow;
        HtmlDocument contentDocument= iframe.GetProperty("contentDocument") as HtmlDocument;
        HtmlDocument document = contentWindow.GetProperty("document") as HtmlDocument;
 
 
        // Hook up the simple JavaScript method HTML button.
        document.GetElementById("btnCallJSMethod").AttachEvent("click",
            new EventHandler(this.CallGlobalJSMethod));
 
            //OR
        //document.GetElementById("btnCallJSMethod").AttachEvent("click",
            //new EventHandler(this.CallGlobalJSMethod));
    }
The JS function is not executed on button's Click in Chrome. We don't believe this is related to HTMLPlaceholder - it simply wraps an iframe object. We changed this ticket's type to Forum. Hope someone from our community has resolved or workarounded this issue.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
HTMLPlaceHolder
Asked by
Hans-Jürgen
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or