public void OnDocumentComplete(object pDisp, ref object URL) { HTMLDocument document = (HTMLDocument)webBrowser.Document; dynamic window = document.parentWindow; IExpando ScriptObject = (IExpando)window; PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default); if (btnEvent == null) { btnEvent = ScriptObject.AddProperty("toQt"); } btnEvent.SetValue(ScriptObject, this, null); IHTMLElement head = (IHTMLElement)((IHTMLElementCollection) document.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script"); scriptObject.type = @"text/javascript"; //scriptObject.text = "alert('aa')"; //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu"; //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) { console.log(data);})"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})"; //document.getElementById(id).contentDocument //scriptObject.text = " $('#input').click(function(){alert('aa')})"; //通知栏所在区域,打开区域 //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*') //病人取药的tables //window.frames[2].frames[0].document.getElementById("gvInfo").innerText //查询按钮 //window.frames[2].frames[0].document.getElementById("btnQuery").value //发药按钮(详情页内) //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao") // 病人信息,名字,性别,年龄 //病人信息(详情页内) //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0]; //table.row[1].cells[10].onmouseover = function(){ alert("ss")} //} //测试调用自定义的DLL window.toQt.ie_add(99,100)+'' // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}"; //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');"; //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //window.frames[2].frames[0].document.getElementById('btnFayao') //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}"; //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')} //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');"; //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};"; //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);"; scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info);window.toQt.sendPatientInfo(info); } } } else { } }, 1000); "; //scriptObject.text = "alert('bcho2.exe')"; ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); }
private static PropertyInfo GetOrCreateProperty(IExpando expando, string name) { PropertyInfo property = expando.GetProperty(name, BindingFlags.Instance); if (property == null) property = expando.AddProperty(name); return property; }
private static object Invoke(IExpando instance, string functionName, InvokeFlags flags, object[] args) { try { args = args.Select(arg => DynamicNode.Unwrap(arg)).ToArray(); switch (flags) { case InvokeFlags.DISPATCH_METHOD: var method = instance.GetMethod(functionName, DefaultFlags); return(method.Invoke(instance, args)); case InvokeFlags.DISPATCH_PROPERTYGET: var getProp = instance.GetProperty(functionName, DefaultFlags); return(getProp.GetValue(instance, null)); case InvokeFlags.DISPATCH_PROPERTYPUT: case InvokeFlags.DISPATCH_PROPERTYPUTREF: var setProp = instance.GetProperty(functionName, DefaultFlags); if (setProp == null) { setProp = instance.AddProperty(functionName); } setProp.SetValue(instance, args[0], null); return(null); default: throw new NotSupportedException(); } } catch (COMException comex) { switch ((uint)comex.ErrorCode) { // Unexpected script error. This will be handled by the IProcess.UnhandledException event case 0x80020101: return(null); default: throw; } } }
private static PropertyInfo GetOrCreateProperty(IExpando expando, string name) { PropertyInfo property = expando.GetProperty(name, BindingFlags.Instance); if (property == null) { property = expando.AddProperty(name); } return(property); }
public static bool Contain(this IExpando expando, string key) { PropertyInfo property = expando.GetProperty(key, BindingFlags.Instance); if (property == null) { FieldInfo f = expando.GetField(key, BindingFlags.Instance); if (f == null) { return(false); } } return(true); }
public static object GetValue(this IExpando expando, string key) { PropertyInfo property = expando.GetProperty(key, BindingFlags.Instance); if (property == null) { FieldInfo f = expando.GetField(key, BindingFlags.Instance); if (f == null) { return(null); } return(f.GetValue(expando)); } return(property.GetValue(expando, null)); }
PropertyInfo GetPropertyInfo(string name, bool create) { if (name == null) { throw new ArgumentNullException("name"); } var result = jsObject.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (result == null && create) { result = jsObject.AddProperty(name); Activated(this); } return(result); }
private string GetPropertyValue(string propertyName) { IExpando domDocumentExpando = (IExpando)HtmlDocument; PropertyInfo errorProperty = domDocumentExpando.GetProperty(propertyName, BindingFlags.Default); if (errorProperty != null) { try { return((string)errorProperty.GetValue(domDocumentExpando, null)); } catch (COMException) { return(null); } } return(null); }
public override bool DeleteProperty(string name) { VerifyNotDisposed(); return(engine.ScriptInvoke(() => { var field = target.GetField(name, BindingFlags.Default); if (field != null) { target.RemoveMember(field); return true; } var property = target.GetProperty(name, BindingFlags.Default); if (property != null) { target.RemoveMember(property); return true; } return false; })); }
public void OnDocumentComplete(object pDisp, ref object URL) { HTMLDocument document = (HTMLDocument)webBrowser.Document; dynamic window = document.parentWindow; IExpando ScriptObject = (IExpando)window; PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default); if (btnEvent == null) { btnEvent = ScriptObject.AddProperty("toQt"); } btnEvent.SetValue(ScriptObject, this, null); IHTMLElement head = (IHTMLElement)((IHTMLElementCollection) document.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script"); scriptObject.type = @"text/javascript"; scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}"; ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); }
private static PropertyInfo CreateOrGetProperty(IExpando expando, string name) { var currentProperty = expando.GetProperty(name, BindingFlags.GetProperty); return(currentProperty ?? expando.AddProperty(name)); }
public void OnDocumentComplete(object pDisp, ref object URL) { HTMLDocument document = (HTMLDocument)webBrowser.Document; dynamic window = document.parentWindow; IExpando ScriptObject = (IExpando)window; PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default); if (btnEvent == null) { btnEvent = ScriptObject.AddProperty("toQt"); } btnEvent.SetValue(ScriptObject, this, null); IHTMLElement head = (IHTMLElement)((IHTMLElementCollection) document.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script"); scriptObject.type = @"text/javascript"; //scriptObject.text = "alert('aa')"; //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu"; //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) { //console.log(data);})"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})"; //document.getElementById(id).contentDocument //scriptObject.text = " $('#input').click(function(){alert('aa')})"; //通知栏所在区域,打开区域 //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*') //病人取药的tables //window.frames[2].frames[0].document.getElementById("gvInfo").innerText //查询按钮 //window.frames[2].frames[0].document.getElementById("btnQuery").value //发药按钮(详情页内) //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao") // 病人信息,名字,性别,年龄 //病人信息(详情页内) //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0]; //table.row[1].cells[10].onmouseover = function(){ alert("ss")} //} //测试调用自定义的DLL window.toQt.ie_add(99,100)+'' // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}"; //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');"; //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //window.frames[2].frames[0].document.getElementById('btnFayao') //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}"; //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')} //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');"; //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);"; //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};"; //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);"; //正确版本 //scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; window.toQt.sendPatientInfo(info);alert('bug--->'+info); } } } else { } }, 1000); "; //scriptObject.text = "function createXMLHttpRequest(){if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlHttp=new ActiveXObject('Microsoft.XMLHTTP')}}return xmlHttp;} "; //scriptObject.text = scriptObject.text+ "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert('22bug'+info); var xmlHttp=createXMLHttpRequest();xmlHttp.onreadystatechange=function(){};xmlHttp.open('POST','http://121.204.198.52:8809/v13/opendata/test/',true);xmlHttp.setRequestHeader('Content-Type','application/json');xmlHttp.send(JSON.stringify({'A':333})); } } } else { } }, 1000); "; //scriptObject.text="function ajax(options) { options = options ||{ }; optoins.type = (options.type || 'GET').toUpperCase(); options.dataType = options.dataType || 'json';params= formatParams(options.data); var xhr; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest()} else { xhr = ActiveXObject('Microsoft.XMLHTTP')} xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { var status = xhr.status; if (status >= 200 && status < 300) { options.success && options.success(xhr.responseText, xhr.responseXML)} else { options.error && options.error(status)} } } if (options.type == 'GET') { xhr.open('GET', options.url + '?' +params, true); xhr.send(null)} else if (options.type == 'POST') { xhr.open('POST', options.url, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(params)} } function formatParams(data) { var arr =[];for(var name in data) { arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name]))} arr.push(('v='Math.random()).replace('.', '')); return arr.join('&')} ajax({ url: 'http://121.204.198.52:8809/v13/opendata/test/',type: 'POST',dataType: 'json',data: { name: '马各马它',age: 18},success: function(response, xml){ },error: function(status){ } });"; //string aa = "hello"; scriptObject.text = @" var old_name = ''; function get_name() { var patient = window.mrightFrame.workFrame.document.getElementById('tbPatient'); return patient.rows[0].cells[5].innerText.split(' ')[0]; } function check() { var name = get_name(); if (name != old_name) { old_name = name; window.toQt.sendPatientInfo(name) //alert(name); } } var times = setInterval(function () { var first = window.mrightFrame; if (first != undefined && first != null) { try { var second = first.workFrame; if (second != undefined && second != null) { try { var d = window.mrightFrame.workFrame.document; if (d != undefined && d != null) { var disabled = window.mrightFrame.workFrame.document.getElementById('btnFayao').disabled; if (disabled == false) check(); } } catch (err) { } } } catch (err) { } } }, 2000); var old_lblname = ''; function get_lblname() { var patient = window.mrightFrame.workFrame.document.getElementById('lblname'); return patient.innerText; } function check2() { var name = get_lblname(); if (name != old_lblname) { old_lblname = name; window.toQt.sendPatientInfo(name) //alert(name); } } var times2 = setInterval(function () { var first = window.mrightFrame; if (first != undefined && first != null) { try { var second = first.workFrame; if (second != undefined && second != null) { try { var patient = window.mrightFrame.workFrame.document; if (patient != undefined && patient != null) { check2(); } } catch (err) { } } } catch (err) { } } }, 2000); "; ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); }
public void OnDocumentComplete(object pDisp, ref object URL) { /* * * HTMLDocument document = (HTMLDocument)webBrowser.Document; * * dynamic window = document.parentWindow; * IExpando ScriptObject = (IExpando)window; * PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default); * if (btnEvent == null) btnEvent = ScriptObject.AddProperty("toQt"); * btnEvent.SetValue(ScriptObject, this, null); * * IHTMLElement head = (IHTMLElement)((IHTMLElementCollection) * document.all.tags("head")).item(null, 0); * * IHTMLScriptElement scriptObject = * (IHTMLScriptElement)document.createElement("script"); * scriptObject.type = @"text/javascript"; * //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}"; * scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}"; * * ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); */ HTMLDocument document = (HTMLDocument)webBrowser.Document; dynamic window = document.parentWindow; IExpando ScriptObject = (IExpando)window; PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default); if (btnEvent == null) { btnEvent = ScriptObject.AddProperty("toQt"); } btnEvent.SetValue(ScriptObject, this, null); IHTMLElement head = (IHTMLElement)((IHTMLElementCollection) document.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script"); scriptObject.type = @"text/javascript"; //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}"; //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu"; //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-8',dataType: 'json',data: JSON.stringify(data),success: function (data) { console.log(data);})"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});"; //scriptObject.text = " $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})"; //document.getElementById(id).contentDocument //scriptObject.text = " $('#input').click(function(){alert('aa')})"; //病人取药的tables //window.frames[2].frames[0].document.getElementById("gvInfo").innerText //查询按钮 //window.frames[2].frames[0].document.getElementById("btnQuery").value scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmousemove = function(){alert('aa');}"; ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); /* * string aa = "{\"hello\":\"C# mircosoft.....\"}"; * string msg= "{\"hello\":\"C# mircosoft.....\"}"; * //http://127.0.0.1:8000/opendata/test/ * //http://121.204.198.52:8809/v13/opendata/test/ * WebRequest request = WebRequest.Create("http://121.204.198.52:8809/v13/opendata/test/"); * request.Method = "POST"; * request.ContentType = "application/json"; * byte[] buf = Encoding.UTF8.GetBytes(aa); * byte[] byteArray = System.Text.Encoding.Default.GetBytes(aa); * request.ContentLength = Encoding.UTF8.GetByteCount(aa); * request.GetRequestStream().Write(buf, 0, buf.Length); * WebResponse response = request.GetResponse(); * Stream myResponseStream = response.GetResponseStream(); * StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); * string retString = myStreamReader.ReadToEnd(); * myStreamReader.Close(); * myResponseStream.Close(); */ }