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 ...
随机推荐
- 木马suppoie 处理的几个思路 木马文件的权限所有者 属主数组 定时任务 目录权限
木马suppoie 处理的几个思路 木马文件的权限所有者 属主数组 定时任务 目录权限
- String类的常用成员方法
1. 构造方法: String(byte[] byte,int offset,int length);这个在上面已经用到. 2. equalsIgnoreCase:忽略大小写的比较,上例中如果您输 ...
- SSH框架-Struts2基础-Action
Struts2的目录结构: 解压apps目录下的struts2-blank.war: 仿照这个最基本的项目,拷贝相关文件: 1.拷贝apps/struts2-blank/WEB-INF/classes ...
- gibhub上搭建个人静态网站介绍
之前学习过git的基本命令.今天介绍一下github上搭建个人网站的步骤. 在window系统上搭建gibhub个人网站(只能执行html.css和js文件),这就是纯静态页面. 步骤一:注册gith ...
- iOS 横向菜单
MKHorizMenu 源码地址 现在想要实现以下效果,其中“选时间”这部分是一个NavigationBar,“日期”是横向的菜单,“电影时段”是TableView. 比较难实现的是横向菜单,因为没有 ...
- ios APP 在 waiting for review时重新上传程序
今天上传程序后发现了一个挺大的bug,想重新上传app,于是搜了一下,现记录一下: 点击details进入后在link点击binary details,进入之后点击右上角reject this bin ...
- 《转》最受欢迎的ASP.NET的CMS下载
1. Umbraco 项目地址 | 下载 Umbraco是一个开放源码的CMS内容管理系统,基于asp.net建立,使用mssql进行存储数据. 使用Umbraco ,设计师能创造出有效的XHTML标 ...
- thrift框架总结,可伸缩的跨语言服务开发框架
thrift框架总结,可伸缩的跨语言服务开发框架 前言: 目前流行的服务调用方式有很多种,例如基于 SOAP 消息格式的 Web Service,基于 JSON 消息格式的 RESTful 服务等.其 ...
- JZOJ.5246【NOIP2017模拟8.8】Trip
Description 多年之后,worldwideD厌倦竞争,隐居山林. 他的家乡开始发展起了旅游业,在一条很长的主干道上,有N个旅游景点,按顺序编号为1到N.根据游客们网 ...
- pro-select-like
DELIMITER | drop procedure if exists pro_query; CREATE PROCEDURE pro_query ( cname VARCHAR() ) BEGIN ...