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.
Changing an Elements innerHTML in TWebBrowser的更多相关文章
- innerHTML的性能问题
看到一遍文章When innerHTML isn’t Fast Enough,反应了innerHTML在操作量大了以后的性能下降的问题. 并且给出了一个replaceHTML的函数 function ...
- 一个酷炫的,基于HTML5,Jquery和Css的全屏焦点图特效,兼容各种浏览器
基于HTML5和CSS的焦点图特效,梅花图案的背景很有中国特色,而且还会动哦,效果超炫,推荐下载! 演示图 html代码 <!DOCTYPE html PUBLIC "-//W3C// ...
- im2uint8函数分析
环境:Win7 64位 + Matlab R2010a 本次分析的函数为im2uint8,这个函数在图像处理中要用到,主要把图像数据类转换到uint8 uint8函数有效的输入的图像数据类为:logi ...
- CSS3入门
CSS3 w3cschools css3 MDN英文 MDN中文 CSS3 is the latest evolution of the Cascading Style Sheets langua ...
- WebSocket实战
前言 互联网发展到现在,早已超越了原始的初衷,人类从来没有像现在这样依赖过他:也正是这种依赖,促进了互联网技术的飞速发展.而终端设备的创新与发展,更加速了互联网的进化: HTTP/1.1规范发布于19 ...
- Golang 学习资料
资料 1.How to Write Go Code https://golang.org/doc/code.html 2.A Tour of Go https://tour.golang.org/li ...
- html lesson one
Review Congratulations on completing the first lesson of HTML & CSS! You are well on your way to ...
- JanusGraph的schema及数据建模
每个JanusGraph都有一个schema,该schema由edge labels, property keys和vertex labels组成.JanusGraph的schema可以显式或隐式创建 ...
- Codeforces 316C2 棋盘模型
Let's move from initial matrix to the bipartite graph. The matrix elements (i, j) for which i + j ar ...
随机推荐
- 微信小程序1 - 扩展app.js
常规的开发过程中, 每个Page的逻辑中,要使用 util.js WapRequest.js, 需要在每个页面中书写 require('/utils/WapRequest'); 略繁琐 在app. ...
- maven项目打ZIP包
1.Maven插件配置: <!-- ZIP打包 --> <plugin> <artifactId>maven-assembly-plugin</artifac ...
- EasyUI DataGrid 编辑单元格
如下图: 现改为单击某个单元格只对此单元格进行可编辑 <TABLE>标记添加 onClickCell <table id="dg" class="eas ...
- redhat ent6.5使用centos yum
转载自:http://blog.csdn.net/zhngjan/article/details/20843465 搜狐镜像库:mirrors.sohu.com 163镜像库:mirrors.163. ...
- java和C#异常处理的差异
Java异常处理和C#非常相似,不过Java中支持强制异常处理方式, 一旦方法加入了throws关键字,那么调用这个方法的类就必须加上try和catch进行异常处理, 如果不处理(没有try catc ...
- nginx已经启动 无法访问页面
通过IP访问,可以看到 welcome nginx 的提示 下面我重启linux服务器,重启后通过ip访问,死活连接不上了?没办法了,只有在百度和google 最后发现问题不是出在nginx上,而是 ...
- resolution will not be reattempted until the update interval of vas has elap
转自:http://kia126.iteye.com/blog/1785120 maven在执行过程中抛错: 引用 ... was cached in the local repository, re ...
- zookeeper简单操作
接下来主要讲述了通过zookeeper服务器自带的zkCli.sh工具模拟客户端访问和操作zookeeper服务器(包括集群服务器). 当成功启动zookeeper服务后,切换到server1/bin ...
- Java一些七七八八的配置
mysql驱动配置连接eclipse和控制台(cmd)(JAVA) https://blog.csdn.net/u013000747/article/details/55510671 BeanUtil ...
- 模态窗口原理及注意事项--http://www.alisdn.com/wordpress/?p=53
前言 在开发Windows引用程序的时候,在一些需要用户确认,或者提示用户注意的场合,经常使用模态对话框,或者叫模态窗口.在绝大多数情况下,模态窗口给开发人员带来了极大的便利,并且在某些应用上有不可替 ...