How to inject HTML and JavaScript into an existing page using C#
-
mercredi 22 février 2012 01:56
I'm working on an add-on for IE which will show an alert pop-up when user visit a specific website. In Fire Fox and Chrome, I did this by injecting pop-up code (in html) in to the body of web page so it will show the alert to user. In IE, I find some ways to inject html into web page like:
http://www.codeproject.com/Articles/149258/Inject-HTML-and-JavaScript-into-an-existing-page-w andhttp://czetsuya-tech.blogspot.com/2011/05/c-insert-dynamic-html-html-injection.html
but the problem is if I use IHTMLDocument2 Interface, I can't inject HTML to a web page having document.body = null. I've been searching so much but still can't find any solution. So my question is there any other way to inject html into body of a web page in IE add-on developemt?
Thank in advance!
Toutes les réponses
-
mercredi 22 février 2012 02:26Under what circumstances is document.body null in IE?
Jose R. MCP
-
mercredi 22 février 2012 10:45
For example is this page: http://minhlinh.us
I did a check in Add-on code and had it to print out the document.body. Then the result was null
-
mercredi 22 février 2012 14:08Wow, really? And the document type is of type IHTMLDocument2? Because I can ask IE8 to show me the source of the page with no issues by hitting F12 and I see the HTML and BODY tags. It just makes sense for it to have a body. If I have time later today I'll do a small test.
Jose R. MCP
-
lundi 27 février 2012 04:05any help, please? :(

