0

Im working a project. a windows form project, C#. an url is entered to textbox and webbrowser control navigates this url, I want to run a javascript this loaded html on webbrowser, but this script is not inside html.

this javascript uses some information in loaded html. this script is created by me for loaded html. but how can I run this script onto html?

a way may be saving loaded html to local disk, and adding javascript, then calling html again.

but this is not effective. Im looking for fastest and very effective automatic way.

anybody ideas?

Thank you so much in advance.

  • 1
    take a look at [this other question](http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control) and see if it helps – Paolo Falabella Jul 27 '11 at 11:00

1 Answers1

0

The most effective method is to put all your javascript functions in a singel file and load them on every page using

 <script type="text/javascript" src="myscripts.js" ></script>

This looks inefficient at first glance until you take into account the bowsers caching behavior.

On the first page it will download the "myscripts.js" file, on all subsequent pages it will pick up the version in the cache.

James Anderson
  • 27,109
  • 7
  • 50
  • 78
  • thank you so much for your reply.but how can I load this script Im using a windows form. and where will I load my scripts? to web browser kontrol? – user865105 Jul 27 '11 at 10:48