i want to add some source code to a webpage to add some functions for my own uses....
for example a webpage has a javascript function a(str){ ..... } i want to add an other function b to filter out some text.. so function a(str) {b(str); .... }..
i want to add some source code to a webpage to add some functions for my own uses....
for example a webpage has a javascript function a(str){ ..... } i want to add an other function b to filter out some text.. so function a(str) {b(str); .... }..
how can i change the source code of a webpage with webbrowser control??
UmairKhan
Ashutosh Kumar
In debug mode it gets rid of the script. But it's already too late.
When I hit viewsource it is still there, but in step-thru debug mode it goes away as n element.
I don't have Navigated event. I'm using the webbrowser com control in .net.
This should not be this hard...anyone
Mazeno
AriesAngel
Capt. KDS
rc-car-crazy
Francis Shanahan
Yo Scorp,
I'm working on this right now as well. No help on the web either. I need to remove a javascript function from the document that's calling a pop-up before it is presented to my webbrowser control.
I have the popup somewhat restrained, but It's making my web auto-processing app take focus (grrr) and now it's time to kill it.
I'm going to try to modify the document.script element. I'll let you know what I come up with.
Jordan2k4
thanks for your reply,, i can change the source(actual its not changing the source, it writes a new html page with the url=about:blank), but the problem is,, after i change the source,, like webbrowser.DocumentText = "<a href='menu.htm'>test</a>"; it will change the source,, but the menu.html is linked to "about:blankmenu.htm" is not the url it should be... and the script from the child frame can't access its parent javascript function,, the permission blocks it.. :(
if i use webbrowser.Document.Write() to write the html code,, it just a blank page,,,, won't show anything,, but the source code is written, i can see it when i right click and choose view source
erick_the_redd
I've moved this thread to the Windows Forums forum. You should have a better chance of getting it answered there.
- Charlie
Awaneesh Pandey
crino
can you modify the source and it still in the same url not in about:blank
if so,, congraduation... i didn't make that works,,,
and for your problem, you can try Navigated event....
U_T_A
I can do this, but it's already too late. The script has already executed
.
Private Sub wb_DownloadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles wb.DownloadComplete
Try
Dim str As String = wb.Document.frames.item(1).document.scripts.item(9).outerHTML
If str.IndexOf("createPopup") > 0 Then wb.Document.frames.item(1).document.scripts.item(9).outerHTML = ""
Catch ex As Exception
End Try
End SubHow can I remove the script before it is rendered in the webbrowser (wb)
Siebe Tolsma
natedev
Thanks Charlie, much appreciated.
The cool thing about the webbrowser control is that you can access the html elements and the entire page source code as its streamed to the client, like when you go to view > source in Internet Explorer for example.
You can change the content on the document_completed event of the webbrowser control if you like.
Now, in terms of actually getting (and setting) the code, take a look at the Document property. This property has pretty much everything for what you want to do. You can get (or set) the inner text/inner html of the current page forms (accessible by index), this maybe what you are after. You can also get (or set) the outer text and outer html properties too.
I think looking at the docs would help you more but hope we have helped in some way :-)
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx