简单htc问题

chenlm 2004-04-07 11:51:28
问题:
为什么这样子这个iframe就是不出现???

a.htc
....................
<PUBLIC:COMPONENT URN="urn:msdn-microsoft-com:workshop" >
<PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="Init()"/>
<PUBLIC:ATTACH EVENT="onclick" ONEVENT="Click()" />
<script>

function Click()
{
alert(element.document.all.frmtest.style.display);//这个没问题
//alert(window.frames["frmtest"].style); 为什么这个是undefined???
}
function Init()
{
oDateIframe=element.document.createElement("IFRAME");
oDateIframe.id = "frmtest";
oDateIframe.style.display = "";
element.document.appendChild(oDateIframe);
window.frames["frmtest"].document.write("<h1>dad</h1>");
window.frames["frmtest"].document.close();
}
</script>
</PUBLIC:COMPONENT>

a.htm
.......................
<table border="1" width="100">
<tr style="behavior:url(a.htc)">
<td>aaa</td><td>bbb</td>
</tr>
</table>
...全文
69 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenlm 2004-04-08
  • 打赏
  • 举报
回复
to: shyslysky(飞天) thanks

再问一个问题

在这个出现的iframe中如何再调用htc中的函数?

window.frames["frmtest"].document.write("<h1>dad</h1><a onclick=Click()>aaa</a>");

这样是不行的
shyslysky 2004-04-08
  • 打赏
  • 举报
回复
element.document.all.frmtest is a reference of IRFRAME object under WINDOW object,
and IRFRAME has style object,
but window.frames["frmtest"] is a reference of WINDOW object,
and WINDOW has not style object,
however, window.frames["frmtest"].document.body has style object,

so three above are object,undefined and object.
shyslysky 2004-04-08
  • 打赏
  • 举报
回复
taste the diffrences of the following:

element.document.all.frmtest.style;
window.frames["frmtest"].style;
window.frames["frmtest"].document.body.style;

shyslysky 2004-04-08
  • 打赏
  • 举报
回复
element.document.appendChild(oDateIframe);
改为
element.document.body.appendChild(oDateIframe);
试试
shyslysky 2004-04-08
  • 打赏
  • 举报
回复
In my opinion, no other way!
chenlm 2004-04-08
  • 打赏
  • 举报
回复
但是如果不用htc的话用js

那么frmtest中可以用 parent.Click() 这样来调用

那么现在用了js改成htc后有没有类似的方法呢?

难道一定要在frmtest中写script?
shyslysky 2004-04-08
  • 打赏
  • 举报
回复
you can not do like this, bucause the page of fratest is another one in which there is not Function Click() .

you can do like the following:

window.frames["frmtest"].document.write("<script language=javascript>function Click(){alert('hi!')}<"+"\/script> ");
window.frames["frmtest"].document.write("<h1>dad</h1><a onclick=Click()>aaa</a>");

Also, you can make Click() in fratest having the same function as Click() in a.htc.

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧