Adding function in javascript using C# (bho)
User Generated
YhpnfNmrirqb
Programming
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!