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. 基于quick-cocos2d-x的LuaSocket范例

    这是一个 luasocket 范例. 为了便于使用,我封装了 luasocket 到 cc.net.SocketTCP 类中.这个范例展示如何使用 cc.net.SocketTCP . 同时,在本范例 ...

  2. SAM I AM UVA - 11419 最小点集覆盖 要输出具体覆盖的行和列。

    /** 题目:SAM I AM UVA - 11419 链接:https://vjudge.net/problem/UVA-11419 题意:给定n*n的矩阵,'X'表示障碍物,'.'表示空格;你有一 ...

  3. mysql—触发器trigger

    触发器(trigger):一种特殊的事物, 监视某种事物操作(insert/update/delete), 并触发相关操作(insert/update/delete). 触发器(trigger)创建4 ...

  4. SVN版本库的备份、还原、移植(初级篇、中级篇和高级篇)

    版本库数据的移植:svnadmin dump.svnadmin load 导出: $svnlook youngest myrepos //查看到目前为止最新的版本号 $svnadmin dump my ...

  5. A Deep Compositional Framework for Human-like Language Acquisition in Virtual Environment

    论文地址:https://128.84.21.199/abs/1703.09831 这篇论文来自于百度的机器学习研究院,作者为:徐伟.余昊男.张海超 这篇论文用了多种技术的组合: reinforcem ...

  6. cuDNN升级

    出错现象ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory 查看当前版本为5.0 ...

  7. JavaScript如何实现计时功能。

    JavaScript如何实现计时功能. 解答:<script> window.setTimeout( “window.location = ‘http://www.csdn.net ‘; ...

  8. 【vijos】1790 拓扑编号(拓扑+贪心)

    https://vijos.org/p/1790 好神的贪心题.. 一开始我也想到了贪心,但是是错的..sad 就是因为每一个节点的编号与逆图的子树有关,且编号一定是>=子树的儿子+1的.但是想 ...

  9. 【BZOJ】3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3400 既然是倍数我们转换成mod.. 设状态f[i][j]表示前i头牛modj的方案 那么答案显然是 ...

  10. Anaconda2+Theano 安装过程中的所有的坑。。。

    写在前面的废话 上次搞theano安装还是一年多以前..anaconda才出到1.4,当时的AnacondaCE,直接安装完基本上theano啥的都一套成功.. 今天换了个电脑,重装anaconda, ...