shlomi gadol

shlomi gadol

  • NA
  • 36
  • 57k

put javascript into webbroswer c#

May 29 2015 2:16 PM
Hi,
 
I am trying to put this html/javascript code into c# webbroswer  control but it shot on script error.
 
This is the javascript code:
 
<!-- START Worden Top Gainers and Losers Ticker Widget -->
<script src="http://widgets.freestockcharts.com/js/jquery-1.3.1.min.js" type="text/javascript"></script> <script src="http://widgets.freestockcharts.com/script/WBIHorizontalTicker2.js?ver=12334" type="text/javascript"></script> <link href="http://widgets.freestockcharts.com/WidgetServer/WBITickerblue.css" rel="stylesheet" type="text/css" />
<script>
var gainerTick = new WBIHorizontalTicker('gainers');
gainerTick.start();
var loserTick = new WBIHorizontalTicker('losers');
loserTick.start();
</script> <!-- End Scrolling Ticker Widget -->
 
 
and this is what I wrote in my c# form init function:
 
webBrowser2.AllowNavigation = true;
webBrowser2.AllowWebBrowserDrop = false;
webBrowser2.IsWebBrowserContextMenuEnabled = false;
webBrowser2.WebBrowserShortcutsEnabled = false;
webBrowser2.ObjectForScripting = this;
 
webBrowser2.DocumentText =
"<script src='http://widgets.freestockcharts.com/js/jquery-1.3.1.min.js' type='text/javascript'></script> " +
"<script src='http://widgets.freestockcharts.com/script/WBIHorizontalTicker2.js?ver=12334' type='text/javascript'></script> " +
"<link href='http://widgets.freestockcharts.com/WidgetServer/WBITickerblue.css' rel='stylesheet' type='text/css' />" +
"<script>" +
"var loserTicker = new WBIHorizontalTicker('losers');"+
"loserTicker.start();"+
"var gainTicker = new WBIHorizontalTicker('gainers');" +
"gainTicker.start();" +
"</script>";
if someone can help, it would be great
 
thanks
 
 

Answers (17)