Programming
Adding function in javascript using C# (bho)

Question Description

Hy  :D  i have one bho (browser helper object ) and i need to add this function in javascript

(

function () {
  var nova = document.getElementById('PartNumberTextBox');
  var so = document.getElementById('so_id');
  var newsn = document.getElementById('new_sn');
  var button = document.getElementById('book_button');
  var newpart = document.getElementById('new_part_no');
  document.body.onkeyup = function (e) {
  if (e === null) e = window.event;
  var code = e.keyCode || e.which;
  if (code == '9') {
  if (e.srcElement == newsn) {
  so.focus();
  } else if (e.srcElement == so) {
  button.focus();
  } else {
  nova.focus();
  }
  }
  };

  nova.onchange = novafunc;
  nova.onblur = novafunc;
  nova.onkeyup = novafunc;
  nova.onmouseup = novafunc;

  function novafunc() {
  if (newpart.value === nova.value && nova.value.length > 0) {
  nova.style.backgroundColor = '#0f0';
  newsn.focus();
  } else {
  nova.style.backgroundColor = '#f00';
  }
  }

})();

to a certain page using c#  ...  ... What's the best solution ?
The page just contains frameset and frames ... and i have used this method to add the textbox on the page ...

  IHTMLElement head= (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
  IHTMLScriptElement scriptObject =(IHTMLScriptElement)document.createElement("script");
  scriptObject.type = @"text/javascript";
  scriptObject.text = @"
 var inp = document.createElement('input');
  inp.id = 'PartNumberTextBox';
  inp.style.position = 'absolute';
  inp.style.right = '6px';
  inp.style.top = '435px';
  inp.style.width = '280px';
  inp.style.backgroundColor = '#000494';
var framex = window.frames;
for (var i = 0; i < framex.length; i++) {
  framex[i].document.body.appendChild(inp);
}";
  ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

can you please help me to add the javascript on the page ? thanks

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors