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. C语言函数sscanf()的用法(转)

    转自:http://www.cnblogs.com/lyq105/archive/2009/11/28/1612677.html C语言函数sscanf()的用法 sscanf() - 从一个字符串中 ...

  2. hdu6055 Regular polygon 脑洞几何 给定n个坐标(x,y)。x,y都是整数,求有多少个正多边形。因为点都是整数点,所以只可能是正四边形。

    /** 题目:hdu6055 Regular polygon 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6055 题意:给定n个坐标(x,y).x,y都 ...

  3. shiro添加注解@RequiresPermissions无效

    在学习和使用shiro中,需要整合shiro框架,然后可以在spring中中使用有三种方法,我用的是注解开发这种方式,但是,我加入注解后发现,没什么作用,然后想着肯定是没有注解成功,然后查找资料,发现 ...

  4. easy ui 验证框的使用

    Easy ui 插件之validatebox missingMessage:未填写时显示的信息validType:验证类型见下示例invalidMessage:无效的数据类型时显示的信息require ...

  5. LBP纹理特征

    LBP-Local Binary Pattern,局部二值模式. 灰度不变性 改进:圆形LBP.旋转不变性 MB-LBP特征,多尺度Multiscale Block LBP: [转载自] 目标检测的图 ...

  6. IPOL图像处理分析经典在线(文献+源码)

    网址: IPOL Journal · Image Processing On Line https://www.ipol.im/ 分类: 搜索: 下载文献和源码: NLM算法:IPOL Journal ...

  7. VC++Debug避免F11步进不想要的函数中

    It's often useful to avoid stepping into some common code like constructors or overloaded operators. ...

  8. jquery 轮播图实例

    实现效果:1.图片每2秒钟切换1次. 2.当鼠标停留在整个页面上时,图片不进行轮播. 3.当点击右下角的小球时,出现该选项的对应图片,而且切换页选项的背景颜色发生相应的变化. 4.当图片发生轮播切换时 ...

  9. cookie的简单留言框

    我们在网页浏览时退出后,再次进入时会有上次的记录,这就用的上cookie属性了,cookie就是服务器暂存放在你计算机上的一笔资料,好让服务器用来辨认你的计算机.当你在浏览网站的时候,Web服务器会先 ...

  10. 在Web工程中,普通Java类如何读文件

    我们在以前讨论过在Web工程不能采用Java工程原先的读取方式,即创建一个文件流(FileInputStream)并给出一个文件目录(从src开始找一直找到你要读取文件的目录),这种的方式是不可行的. ...