Changing an Elements innerHTML in TWebBrowser
I'm unable to change the innerHTML of a javascript element, but i can change the id so i'm not sure why it wont work.
i get OLE error 800A0258.
Any help will be great, thanks.
===========================
"innerHTML of a javascript element" ...uhm what?
first: all things you can access thru TWebBrowser is called DOM and im sure you want to set the property "innerHTML" of an HTML-(container)-tag. have you ensured that you accessed the object correctly? try your assigning out of delphi within a javascript block and see if that works. have you also tried "innerText" instead?
==================================
I cant remember the error.
this is how i dot it now
procedure DoUpdate;
var
document: IHTMLDocument2;
FE: IHTMLElement;
Res:TResourceStream;
Str:TStringStream;
Tmp:String;
begin
document:= frmMain.List.Document as IHTMLDocument2;
FE:= document.scripts.item(0, '') as IHTMLElement;
if (FE <> nil) and (FE.id <> JSv) then begin
Res:= TResourceStream.CreateFromID(hInstance, 1, 'TEXT');
Str:= TStringStream.Create('');
Res.Seek(0, 0);
Str.CopyFrom(Res, Res.Size);
Tmp:= '<script language=javascript id='+JSv+'>';
Tmp:= Copy(Str.DataString, Pos(Tmp, LowerCase(Str.DataString)), Pos('</script>', LowerCase(Str.DataString))-Pos(Tmp, LowerCase(Str.DataString))+9);
Str.Free;
Res.Free;
FE.outerHTML:= '<br id=del>'+Tmp;
((frmMain.List.Document as IHTMLDocument2).parentWindow).execScript('document.body.removeChild(document.getElementById("del"));', 'JavaScript');
Tmp:= '';
end;
end;
JSv is the Script version.
=================================================
innerHTML does not apply to all elements.
For details see:
"The property is read/write for all objects except the following, for which it is read-only: COL, COLGROUP, FRAMESET, HTML, STYLE, TABLE, TBODY, TFOOT, THEAD, TITLE, TR."
and
"By definition, elements that do not have both an opening and closing tag cannot have an innerHTML property."
For example when you try to set innerHTML for an <IMG> (which has noc closing tag) the above ole-error may occur.
最新文章
- Linux命令【第二篇】
- 简单的jQuery幻灯片实现
- flask 链接 url_for()
- centos查找未挂载磁盘格式化并挂载
- Why is processing a sorted array faster than an unsorted array?
- [moka同学笔记]yii2场景的使用(摘录)
- SQL Server 重新恢复自动编号列的序号
- jquery.uploadify+spring mvc实现上传图片
- 工作流Activiti5.13学习笔记(一)
- Python之面向对象二
- CentOS配置
- k8s源码分析准备工作 - 源码准备
- 【转】C#中判断网址是否有效
- 一个简单的scrollTop动画的方法
- loj 10181 绿色通道 二分答案+单调队列DP
- js原生事件
- [LeetCode] 193. Valid Phone Numbers_Easy tag: Bash
- 泛型编程之特性(traits)
- 5.mybatis实战教程(mybatis in action)之五:与spring3集成(附源码)
- centos7 端口转发
热门文章
- hdu6007 Mr. Panda and Crystal 最短路+完全背包
- idea编译修改jdk版本
- Oracle Tuning ( instance 级别 ) 01
- hibernate中的java对象有几种状态,其相互关系如何(区别和相互转换)。
- 【Raspberry pi】GPIO注意事项
- 振铃效应(ringing artifacts)
- VC++调节显示器的亮度SetDeviceGammaRamp
- Spring配置dataSource的三种方式 数据库连接池
- jquery 轮播图实例
- 160628、利用Oracle rownum让表排序字段值连续