Trouble inserting javascript to current webpage using C#
<p>I am encountering a problem with not being able to inject javascript through a webbrowser contol without writing to a new html. Is there a way to inject a string of javascript to the currently browsed webpage? </p>

<pre><code>javascript:(function(){var s=document.createElement('script');s.setAttribute('src','file:///C:/abc.js');document.getElementsByTagName('head')[0].appendChild(s);})()
</code></pre>

<p>The current method I am using involves stringbuilder and webbrowser w/ windows.forms.document</p>

<pre><code>string js = @"&lt;script type='text/javascript'&gt;function test(){alert(test)}&lt;/script&gt;";
WebBrowser wb = new WebBrowser();
wb.Url = new Uri("http://www.google.com");
wb.Document.Write(js);              
wb.Document.InvokeScript("test");
</code></pre>

<p>What am I doing wrong? Is there a better working way of approaching this?</p>
