设置innerHTML [英] Setting innerHTML

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

问题描述

嘿,


我有一个DIV,我想动态设置它的innerHTML。我知道我可以通过执行以下操作来设置它:myDiv.innerHTML =''< img

src = \" myImage.gif \"> ''

但是,我想在其中设置的html非常大,所以我不会想要像我刚才那样对HTML进行硬编码。

我的问题是......是否可以将现有的html页面分配给

innerHTML。

例如myDiv.innerHTML =''mytest.html''

因此mytest.html的内容将设置在myDiv的

innerHTML中。


谢谢,


克里斯

Hey,

I have a DIV and I want to dynamically set its innerHTML. I know I can
set it by doing the following myDiv.innerHTML = ''<img
src=\"myImage.gif\">''
However, the html that I want to set in it is quite large so I dont
want to have to hard code the HTML like I just did.
My question is....is it possible to assign an existing html page to the
innerHTML.
e.g. myDiv.innerHTML = ''mytest.html''
So that the contents of the mytest.html would be set in myDiv''s
innerHTML.

Thanks,

Chris

推荐答案

Chris Moltisanti写道:
Chris Moltisanti wrote:
嘿,

我有一个DIV,我想动态设置它的innerHTML。我知道我可以通过以下方式设置它:myDiv.innerHTML =''< img
src = \" myImage.gif \">''
但是,我想在其中设置的html非常大,所以我不想像我刚才那样对HTML进行硬编码。
我的问题是......是否可以分配现有的html页面到
innerHTML。


排序。

例如myDiv.innerHTML =''mytest.html''


这会将innerHTML设置为''mytest.html''

所以mytest.html的内容将在myDiv的
innerHTML中设置。
Hey,

I have a DIV and I want to dynamically set its innerHTML. I know I can
set it by doing the following myDiv.innerHTML = ''<img
src=\"myImage.gif\">''
However, the html that I want to set in it is quite large so I dont
want to have to hard code the HTML like I just did.
My question is....is it possible to assign an existing html page to the
innerHTML.
Sort of.
e.g. myDiv.innerHTML = ''mytest.html''
That would set the innerHTML to, literally, ''mytest.html''
So that the contents of the mytest.html would be set in myDiv''s
innerHTML.



XMLHttpRequest(又名AJAX) - 调用页面,获取响应字符串,

将响应字符串应用于myDiv.innerHTML



XMLHttpRequest (aka AJAX) - call the page, get back the response string,
apply the response string to the myDiv.innerHTML


感谢您的回复。


我有点使用AJAX,我不熟悉使用AJAX调用pag

。有关语法的任何想法吗?

我认为AJAX更适合拨打服务器电话.......


Chris。

Thanks for the reply.

I have use AJAX a little bit, bu I am unfamiliar with calling a pag
with AJAX. Any ideas on the syntax to do this?
I thought AJAX was more for making server calls.......

Chris.


Chris Moltisanti于2006年6月6日在comp.lang.javascript写了
Chris Moltisanti wrote on 06 jun 2006 in comp.lang.javascript:
谢谢回复。




回复什么?


请引用您所回复的内容。

如果您想通过groups.google.com发布后续内容,请不要使用

"回复"链接在文章的底部。点击显示选项在文章顶部的

,然后点击回复按钮。在文章的底部

标题。


< http://www.safalra.com/special/googlegroupsreply/>


-

Evertjan。

荷兰。

(请将x''改为点我的电子邮件地址)



What reply?

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don''t use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers.

<http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


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

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