在 TWebBrowser 控件中执行javascript代码

页面上包含 Jquery ,所以在delphi中定义的js代码是 jquery代码

 

ExpandedBlockStart.gif
procedure  TFormLogin.Login();
var
  JSFun, newPw: 
string ;
begin
  newPw :
=   ' <input name=''pw'' id=''pw'' type=''text'' class=''input'' tabindex=''2'' maxlength=''16'' οnkeypress=''if(event.keyCode == 13){login();}'' autocomplete=''off'' value='' '   +  edtPwd.Text  +   ' ''> ' ;
  
try
    
//  JSFun : =   ' login_tab_click(''nexon''); ' //  转到左侧
    JSFun :
=   ' login_tab_click(''dnf''); ' //  转到右侧
    htmlWindow.execScript(JSFun, 
' JavaScript ' );
    JSFun :
=   ' $("#id").focus();$("#id").val(" '   +  edtUName.Text  +   ' "); ' ;
    htmlWindow.execScript(JSFun, 
' JavaScript ' );
    JSFun :
=   ' $("#pw").click();$("#pw").replaceWith(" '   +  newPw  +   ' "); ' ;
    htmlWindow.execScript(JSFun, 
' JavaScript ' );
    JSFun :
=   ' login(); ' ;
    htmlWindow.execScript(JSFun, 
' JavaScript ' );
  
except
  
end ;
end ;

 

转载于:https://www.cnblogs.com/heimirror/archive/2010/10/16/1853033.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值