document.body.innderHTML [英] document.body.innderHTML

查看:92
本文介绍了document.body.innderHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我为什么这样有效:


document.body.innerHTML =

"< table>< tr>< th>一个< / th>< / tr>< tr>< td>二< / td>< / tr>< / table>" ;;


但这不起作用:

document.body.innerHTML ="< table>< tr>" ;;

document.body.innerHTML = document.body .innerHTML +

"< th> one< / th>< / tr>< tr>< td> 2< / td>< / tr>< / table> " ;;


谢谢

Can someone please tell me why this works:

document.body.innerHTML =
"<table><tr><th>one</th></tr><tr><td>two</td></tr></table>";

But this does not work:
document.body.innerHTML = "<table><tr>";
document.body.innerHTML = document.body.innerHTML +
"<th>one</th></tr><tr><td>two</td></tr></table>";

Thanks

推荐答案

于2005年10月20日在comp.lang上写道.javascript
wrote on 20 sep 2005 in comp.lang.javascript:
有人可以告诉我为什么会这样:

document.body.innerHTML =
" ;<表>< TR><第 - 酮< /第>< / TR>< TR>< TD>二< / TD>< / TR>< /表>英寸;

但这不起作用:
document.body.innerHTML =&qu ot;< table>< tr>" ;;
document.body.innerHTML = document.body.innerHTML +
"< th> one< / th>< / tr>< ; tr>< td>二< / td>< / tr>< / table>" ;;
Can someone please tell me why this works:

document.body.innerHTML =
"<table><tr><th>one</th></tr><tr><td>two</td></tr></table>";

But this does not work:
document.body.innerHTML = "<table><tr>";
document.body.innerHTML = document.body.innerHTML +
"<th>one</th></tr><tr><td>two</td></tr></table>";




也许是因为你的身体内有脚本,

并且在第二个例子的第一行执行

时该脚本丢失。

-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)



Perhaps because you have the script inside the body,
and that script is lost in execution of
the first line of your second example.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)




< ch **************** @ gmail.com>在消息中写道

news:11 ********************* @ o13g2000cwo.googlegro ups.com ...

<ch****************@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
有人可以告诉我为什么这样做:

document.body.innerHTML =
"< table>< tr>< th> one< / th>< ; / tr>< tr>< td>二< / td>< / tr>< / table>" ;;

但这不起作用:
文件。 body.innerHTML ="< table>< tr>" ;;
document.body.innerHTML = document.body.innerHTML +
"< th> one< / th>< / tr>< tr>< td>两个< / td>< / tr>< / table>" ;;
Can someone please tell me why this works:

document.body.innerHTML =
"<table><tr><th>one</th></tr><tr><td>two</td></tr></table>";

But this does not work:
document.body.innerHTML = "<table><tr>";
document.body.innerHTML = document.body.innerHTML +
"<th>one</th></tr><tr><td>two</td></tr></table>";




您需要"文件,身体..."是javascript,你只是创建一个

表并在其中添加文本文档,不会处理正文内容。



you would need "document,body..." is javascript and you are just creating a
table and adding text to it the document,body stuff will not be processed.


Evertjan。写道:
Evertjan. wrote:
也许是因为你的体内有脚本,
并且在第二个例子的第一行执行时该脚本丢失了。
Perhaps because you have the script inside the body,
and that script is lost in execution of
the first line of your second example.




感谢您的帮助,但不,我不是那么愚蠢。


我不确定我是否可以减少并通过谷歌组粘贴HTML。我是

不确定这是否会出现。


< html>

< head>

< script language =" JavaScript">


function duh(){

//这将work:

document.body.innerHTML =

"< table>< tr>< th> one< / th>< / tr>< tr>< td> 2< / td>< / tr>< / table>" ;;


//这不起作用(取消注释以便自己查看

/ *

document.body.innerHTML ="< table>< tr>" ;;

document.body.innerHTML = document.body.innerHTML +

"< th> one< / th>< / tr>< tr>< td> two< / td>< / tr>< / table>" ;;

* /

}

< / script>

< / head> ;

< body onload =" duh()">

< / body>

< / html>



Thanks for trying to help, but no, I''m not quite that stupid.

I''m not sure if I can cut and paste html through google groups. I''m
not sure if this is going to show up or not.

<html>
<head>
<script language="JavaScript">

function duh() {
// this will work:
document.body.innerHTML =
"<table><tr><th>one</th></tr><tr><td>two</td></tr></table>";

// this will not work (uncomment it to see for yourself
/*
document.body.innerHTML = "<table><tr>";
document.body.innerHTML = document.body.innerHTML +
"<th>one</th></tr><tr><td>two</td></tr></table>";
*/
}
</script>
</head>
<body onload="duh()">
</body>
</html>


这篇关于document.body.innderHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆