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:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/innerhtml.asp

"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的更多相关文章

  1. innerHTML的性能问题

    看到一遍文章When innerHTML isn’t Fast Enough,反应了innerHTML在操作量大了以后的性能下降的问题. 并且给出了一个replaceHTML的函数 function  ...

  2. 一个酷炫的,基于HTML5,Jquery和Css的全屏焦点图特效,兼容各种浏览器

    基于HTML5和CSS的焦点图特效,梅花图案的背景很有中国特色,而且还会动哦,效果超炫,推荐下载! 演示图 html代码 <!DOCTYPE html PUBLIC "-//W3C// ...

  3. im2uint8函数分析

    环境:Win7 64位 + Matlab R2010a 本次分析的函数为im2uint8,这个函数在图像处理中要用到,主要把图像数据类转换到uint8 uint8函数有效的输入的图像数据类为:logi ...

  4. CSS3入门

    CSS3 w3cschools css3  MDN英文  MDN中文 CSS3 is the latest evolution of the Cascading Style Sheets langua ...

  5. WebSocket实战

    前言 互联网发展到现在,早已超越了原始的初衷,人类从来没有像现在这样依赖过他:也正是这种依赖,促进了互联网技术的飞速发展.而终端设备的创新与发展,更加速了互联网的进化: HTTP/1.1规范发布于19 ...

  6. Golang 学习资料

    资料 1.How to Write Go Code https://golang.org/doc/code.html 2.A Tour of Go https://tour.golang.org/li ...

  7. html lesson one

    Review Congratulations on completing the first lesson of HTML & CSS! You are well on your way to ...

  8. JanusGraph的schema及数据建模

    每个JanusGraph都有一个schema,该schema由edge labels, property keys和vertex labels组成.JanusGraph的schema可以显式或隐式创建 ...

  9. Codeforces 316C2 棋盘模型

    Let's move from initial matrix to the bipartite graph. The matrix elements (i, j) for which i + j ar ...

随机推荐

  1. HTTP抓包工具Charles分析

    Charles是一款抓包神器,它是Java开发的跨平台的软件,不仅可以在Mac上使用,Linux以及Window下都是可以使用的,当然需要安装JDK,才能运行,他是收费的,需要进行破解. 破解操作:将 ...

  2. EM算法--原理

    EM算法即期望最大化(Expection Maximization)算法,是一种最优化算法,在机器学习领域用来求解含有隐变量的模型的最大似然问题.最大似然是一种求解模型参数的方法,顾名思义,在给定一组 ...

  3. 【Raspberry Pi】读取DHT11温度湿度波折

    从网上找到了DHT11厂家说明书,尝试用python根据时序图写数据获取驱动,但发现python的高层特性导致在做底层代码时例如控制20us时延这类需求就没什么好的办法. 还是得回到C-wiringP ...

  4. 更改Ubuntu的默认开机启动项

    终端下: sudo vim /etc/default/grub 修改以下红色语句即可,注意是从0开始: GRUB_DEFAULT=5 #GRUB_HIDDEN_TIMEOUT= GRUB_HIDDEN ...

  5. 【matlab】生成列是0-255渐变的图像

    图像大小:640×512 8位灰度图 %% 生成图像 %大小:* %类型:灰度图 %灰度值:列按照0-255渐变,故命名为column shade. clc,clear all,close all; ...

  6. linux配置sftp用户的chroot步骤(用户的sftp根文件夹)

    1.编辑ssh中的sftp的配置,命令可能是:vi /etc/ssh/sshd_config 在这个文件里最后增加 #限制sftp组的用户使用sftp时在自己的home文件夹下 Match Group ...

  7. 使用JMX监控Kafka

    监控数据源 JMX RMI方式启动Broker,Consumer,Producer -ea -Dcom.sun.management.jmxremote.authenticate=false -Dco ...

  8. HDU 3695 / POJ 3987 Computer Virus on Planet Pandora

      Computer Virus on Planet Pandora Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1353 ...

  9. [Algorithms] Graph Traversal (BFS and DFS)

    Graph is an important data structure and has many important applications. Moreover, grach traversal ...

  10. Jmeter--CSV Data Set Config 参数化配置

    博客首页:http://www.cnblogs.com/fqfanqi/ 设置界面如下: Filename:参数文件名,一般是.csv和.txt文件.绝对路径和相对路径都可以,为了便于脚本迁移,建议使 ...