使用Javascript从外部页面获取innerhtml [英] Get innerhtml from external page with Javascript

查看:90
本文介绍了使用Javascript从外部页面获取innerhtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取位于外部页面上的DIV的innerHTML。

I'm trying to get innerHTML of a DIV that is located on external page. It is possible to do this using this kind javascript code?

    <script type="text/javascript">
        $(document).ready(function(){
            var html = document.getElementById("glr1").src='/my_page.html'.innerHTML ;
            alert(html);
        });
    </script>


推荐答案

jquery加载函数允许你指定一个元素id加载

the jquery load function allows you to specify an element id to load

$('#result').load('ajax/test.html #container');

http://api.jquery.com/load/

这篇关于使用Javascript从外部页面获取innerhtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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