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 ...
随机推荐
- fiddler获取手机请求
最近由于项目的关系,一直在测试APP,但是比较令人头痛的问题就是,APP的测试没有办法像web的测试那样,可以直接的通过开发工具看到请求和响应,对于一些东西只能去看日志(比较麻烦),偶然间发现了fid ...
- 利用:header匹配所有标题做目录
1.问题背景 查找到h1-h6,并遍历它们,打印出内容 2.实现源码 <!DOCTYPE html> <html> <head> <meta charset= ...
- xml传输过程中中文乱码
------------------------------------------request:----------------------------------------------- pu ...
- php ajax dom---动态增加
js代码 <script type="text/javascript"> $(document).ready(function(){ $("#talk_sen ...
- js json ie不支持json
JSON是包含在JScript 5.8中,而为了向下兼容ie8只有在文档模式是”Internet Explorer 8 Standards”的时候才使用JScripte 5.8,其他时候使用JScri ...
- 更改Ubuntu的默认开机启动项
终端下: sudo vim /etc/default/grub 修改以下红色语句即可,注意是从0开始: GRUB_DEFAULT=5 #GRUB_HIDDEN_TIMEOUT= GRUB_HIDDEN ...
- android手机有多个摄像头,打开其中一个
方法: private Camera openFrontFacingCameraGingerbread() { int cameraCount = 0; Camera cam = null; Came ...
- 怎么用ChemDraw 15.1 Pro绘制彩色结构
ChemOffice 15是最新的ChemDraw化学工具套件,合理的使用这套软件可以大幅度的提高研究人员的工作效率.也有一些化学老师使用这套化学绘图软件教学,其可以绘制彩色结构有效增强教案说服力并吸 ...
- CodeFirst中DbContext动态添加DbSet
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- JMeter学习-021-JMeter 定时器的应用
定时器类型 下面我们看下jmeter提供了哪些定时器组件: 固定定时器 高斯随机定时器 Uniform Random Timer Synchronizing Timer Poisson Random ...