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.

最新文章

  1. Linux命令【第二篇】
  2. 简单的jQuery幻灯片实现
  3. flask 链接 url_for()
  4. centos查找未挂载磁盘格式化并挂载
  5. Why is processing a sorted array faster than an unsorted array?
  6. [moka同学笔记]yii2场景的使用(摘录)
  7. SQL Server 重新恢复自动编号列的序号
  8. jquery.uploadify+spring mvc实现上传图片
  9. 工作流Activiti5.13学习笔记(一)
  10. Python之面向对象二
  11. CentOS配置
  12. k8s源码分析准备工作 - 源码准备
  13. 【转】C#中判断网址是否有效
  14. 一个简单的scrollTop动画的方法
  15. loj 10181 绿色通道 二分答案+单调队列DP
  16. js原生事件
  17. [LeetCode] 193. Valid Phone Numbers_Easy tag: Bash
  18. 泛型编程之特性(traits)
  19. 5.mybatis实战教程(mybatis in action)之五:与spring3集成(附源码)
  20. centos7 端口转发

热门文章

  1. hdu6007 Mr. Panda and Crystal 最短路+完全背包
  2. idea编译修改jdk版本
  3. Oracle Tuning ( instance 级别 ) 01
  4. hibernate中的java对象有几种状态,其相互关系如何(区别和相互转换)。
  5. 【Raspberry pi】GPIO注意事项
  6. 振铃效应(ringing artifacts)
  7. VC++调节显示器的亮度SetDeviceGammaRamp
  8. Spring配置dataSource的三种方式 数据库连接池
  9. jquery 轮播图实例
  10. 160628、利用Oracle rownum让表排序字段值连续