Webbrowser injection Javascript script in WPF

Source: Internet
Author: User

The webbrowser of WPF differs from that of winform.

 

To inject a Javascript script into it, after my own test, the following path can be used:

 

 Mshtml. htmldocument htmldoc = browser. document as mshtml. htmldocument; <br/> var head = htmldoc. getelementsbytagname ("head "). cast <ptmlheadelement> (). first (); <br/> var script = (ihtmlscriptelement) htmldoc. createelement ("script"); <br/> script. TEXT = "alert ('Hello World')"; <br/> head. appendchild (ihtmldomnode) script );

 

This method can also inject Javascript functions and call browser. invokescript () as needed.

 

But today I found a strange problem .. I used this injection method to modify document. Body. style. Zoom. The whole page is scaled, but the flash and other controls are faulty ..

 

Then I used the developer tool in IE8 to inject and modify document. Body. style. Zoom...

 

That's strange. I will continue the study the next day.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.