以字符串形式获取HTML源代码 [英] Get HTML source code as a string

查看:54
本文介绍了以字符串形式获取HTML源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望HTML页面( 1.html )的源代码可以在另一个页面( 2.html )中使用.此外,我想在 2.html 中对其进行操作.

有没有办法做到这一点?

1.html 是一个单独的公共网页,我无权对其源代码进行更改.我只需要使用 2.html .

解决方案

要将DOM转换为字符串:

  document.getElementsByTagName('html')[0] .innerHTML 

问题:使用它"是什么意思?您是否需要在2.html中包含1.html?还是只需要处理它?<​​/p>

I want the source code of an HTML page (1.html) to be used in another page (2.html). Furthermore, I want to perform operations on it in 2.html.

Is there a way to do this?

EDIT: 1.html is a separate public webpage and I do not have access to make changes to its source code. I have to do whatever I need only by using 2.html.

解决方案

To get the DOM converted to a string:

document.getElementsByTagName('html')[0].innerHTML

Question: what do you mean by "use it"? Do you need to include 1.html inside 2.html? Or do you just need to process it?

这篇关于以字符串形式获取HTML源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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