如果您在页面上使用了createElement()和appendChild(),那么如何捕获要写入PHP的所有HTML? [英] if you have used createElement() and appendChild() on a page, how do you capture all the HTML to write to PHP?

查看:64
本文介绍了如果您在页面上使用了createElement()和appendChild(),那么如何捕获要写入PHP的所有HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力学习AJAX,所以今晚我坐下来想出了一个可以用来测试的小玩具。你可以在这里看到:

http:// www。 publicdomainsoftware.org/ajaxExperiment.htm


我有Stuart Langridge的书DHTML Utopia:现代网页设计使用

Javascript和DOM这似乎很不错。它涵盖了基础知识。


我想做的下一件事就是在这个小页面上添加一个Save按钮

我想出了。我可以使用Sam Stephenson的Prototype框架来将
页面写入PHP脚本。然后将整个东西写成平局文件。这将是一个有趣的小玩具。


我在书中看不到的唯一一件事是,我如何得到所有的
$ b通过使用createElement()和appendChild()来广泛地改变HTML后,页面中的$ b文本和HTML?也就是说,

如何捕获我想发送给PHP的所有材料?

脚本?

I''m trying to learn AJAX so tonight I sat down and came up with a
little toy that I can do tests with. You can see it here:

http://www.publicdomainsoftware.org/ajaxExperiment.htm

I''ve got Stuart Langridge''s book "DHTML Utopia: Modern Web Design using
Javascript and DOM" which seems pretty good. It covers the basics.

The next thing I''d like to do is add a Save button to this little page
I came up with. I may use Sam Stephenson''s Prototype framework to
write the page to a PHP script. Which will then write the whole thing
out as a flat file. That would be a fun little toy to play with.

The only thing that I don''t see in the book is, how do I get all the
text and HTML that is in the page after that HTML has been extensively
changed through the use of createElement() and appendChild()? That is,
how do I capture all the material that I''d like to send to that PHP
script?

推荐答案

我应该在我的原始帖子中添加,当你去那个页面

时,你应该点击某些内容开始播放。

杰克巴恩斯写道:
I should have added, to my original post, that when you go that page
you should click on something to start playing.
Jake Barnes wrote:
我正在努力学习AJAX,所以今晚我坐下来想出了一个我可以做测试的小玩具。你可以在这里看到:

http:// www。 publicdomainsoftware.org/ajaxExperiment.htm

我有Stuart Langridge的书DHTML乌托邦:使用Javascript和DOM的现代网页设计这似乎很不错。它涵盖了基础知识。

接下来我要做的是在这个小页面上添加一个Save按钮
我想出了。我可以使用Sam Stephenson的Prototype框架将页面写入PHP脚本。然后将整个事物写成平面文件。这将是一个有趣的小玩具。

我在书中看不到的唯一一件事是,如何获得所有的文本和HTML通过使用createElement()和appendChild()来广泛改变HTML之后的页面?也就是说,我如何捕获我想要发送到PHP
脚本的所有材料?
I''m trying to learn AJAX so tonight I sat down and came up with a
little toy that I can do tests with. You can see it here:

http://www.publicdomainsoftware.org/ajaxExperiment.htm

I''ve got Stuart Langridge''s book "DHTML Utopia: Modern Web Design using
Javascript and DOM" which seems pretty good. It covers the basics.

The next thing I''d like to do is add a Save button to this little page
I came up with. I may use Sam Stephenson''s Prototype framework to
write the page to a PHP script. Which will then write the whole thing
out as a flat file. That would be a fun little toy to play with.

The only thing that I don''t see in the book is, how do I get all the
text and HTML that is in the page after that HTML has been extensively
changed through the use of createElement() and appendChild()? That is,
how do I capture all the material that I''d like to send to that PHP
script?








Jake Barnes写道:


Jake Barnes wrote:
书中我唯一没看到的是,我该怎么办?通过使用createElement()和appendChild()来广泛地改变HTML后,获取页面中的所有文本和HTML?也就是说,我如何捕获我想要发送到PHP
脚本的所有材料?
The only thing that I don''t see in the book is, how do I get all the
text and HTML that is in the page after that HTML has been extensively
changed through the use of createElement() and appendChild()? That is,
how do I capture all the material that I''d like to send to that PHP
script?




HTML元素节点在IE的浏览器DOM中,Opera和其他人都有

属性名为

outerHTML

innerHTML

当访问时序列化节点及其内容(outerHTML)或

节点的内容(innerHTML)。

Mozilla仅支持innerHTML。

请注意如果序列化可能不是标记的形式,那么在人们将XHTML作为text / html提供给浏览器的时候,你需要寻找





Mozilla和Opera和Safari我认为还提供了一个XMLSerializer,它可以应用于DOM节点,但正如名称所说它主要用于

根据XML而不是HTML进行序列化。然而

新的XMLSerializer()。serializeToString(htmlDOMNode)

可以在这些浏览器中完成。


-


Martin Honnen
http://JavaScript.FAQTs。 com /




Jake Barnes写道:

Jake Barnes wrote:
我在书中没有看到的唯一的事情是,在通过使用createElement()广泛地改变HTML之后,如何获得页面中的所有文本和HTML?和appendChild()?也就是说,我如何捕获我想要发送到PHP
脚本的所有材料?
The only thing that I don''t see in the book is, how do I get all the
text and HTML that is in the page after that HTML has been extensively
changed through the use of createElement() and appendChild()? That is,
how do I capture all the material that I''d like to send to that PHP
script?




假设你想在编辑后保存整个页面:


....

var pageContent = document.documentElement.innerHTML;

....

现在pageContent包含打开< HTML>的所有内容。关闭

< / HTML>包括< HTML>标记自己



Presuming that you want to save the whole page after editing:

....
var pageContent = document.documentElement.innerHTML;
....
Now pageContent contains everything from opening <HTML> to closing
</HTML> including <HTML> tags themselves


这篇关于如果您在页面上使用了createElement()和appendChild(),那么如何捕获要写入PHP的所有HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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