Javascript:获取当前页面CURRENT源码 [英] Javascript: Get current page CURRENT source

查看:135
本文介绍了Javascript:获取当前页面CURRENT源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  document.documentElement.outerHTML 
我有HTML,我需要获得这个html的页面源代码。

  $ .ajax({
async:true,
类型:'GET',
cache:false,
url:window.location.href,
成功:函数(data){
alert(data);
}
});

正在工作,但它们显示的是原始来源。如果我改变html(例如jQuery),它们不会读取我的更改。



是否可以读取CURRENT页面源?

解决方案

在Chrome上尝试了它,它工作。使用

  document.documentElement.innerHTML 

有趣的是,你的代码也可以工作了

  document.documentElement.outerHTML 
code>

查看在 小提琴 。它实际上包含了jQuery所做的更改。


I have HTML and I need to get page source of this html.

document.documentElement.outerHTML

or

$.ajax({
async: true,
type: 'GET',
cache: false,
url: window.location.href,
success: function(data) {
   alert(data);
}
});

is working, but they display originally source. If I change html (by jQuery, for example), they don't read my changes.

Is it possible read CURRENT source of page?

解决方案

Tried it on chrome and it works. Use

document.documentElement.innerHTML

Funnily enough your code also worked

document.documentElement.outerHTML

Check out the html printed to the console in this fiddle. It actually contains the changes made by jQuery.

这篇关于Javascript:获取当前页面CURRENT源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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