How to inject javaScript to iframe ? RRS feed

  • Question

  • I have a webview load external page like : http://google.com...

    I use invokeScriptAsync to invoke JS to webview. But don't know detail code javaScript to add function from mainpage to iframe.

    How to inject javaScript to all iframe ?

    Here is demo code use local html (reality use external).

    <!DOCTYPE html>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
    // How to inject javaScript to all iframe ?
    <p>Click the button to open a new browser window.</p>
    <a href="http://www.google.com" target="_blank">CLICK</a>
    <iframe width="800" height="800" ></iframe>

    Wednesday, January 14, 2015 2:04 PM

All replies

  • What do you mean by "all" iframe? Where are the iframes located? In the rendered HTML page inside the WebView or somewhere else?

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Thursday, January 15, 2015 12:43 AM
  • "All" frames mean that, in HTML page maybe contain many iframes. iframe is located in HTML page.

    This is My issues :  I implement Browser using WebView, but when I click on link embedded in iframe like Facebook like button, but the link is opened by Device Default Browser, not in my browser.

    So I want to inject my javascript to iframe to fix this issue?

    Do you have any suggestion? 

    Thursday, January 15, 2015 3:14 AM