在另一个html里面查看html页面 [英] view html page inside another html

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

问题描述

我想知道如何将html页面包含在另一个html
中,因为我不使用任何服务器端语言,我只是想通过html和css来实现它。
我想单击锚点,然后在页面的中心div中显示html,因为我将html页面划分为页眉,页脚和body。

div 。将它绑定到锚点的click事件,如下所示:

  $('#myanchor')。click(function() {
$ .get('mypage.html',function(data){
$('#mydiv')。html(data);
});
}) ;

(请注意,这是手写代码,我没有测试过,但您明白了。 )

I want to know how can i include html page inside another html since i don't use any server side languages, I just want to make it through html and css. I want to click over anchor and then display the html in the center div of the page, since i devide the html page to header, footer, and body.

解决方案

You can use jQuery to fetch the HTML page from the server and set its contents within the desired div. Just bind it to the anchor's click event, something like this:

$('#myanchor').click(function() {
    $.get('mypage.html', function(data) {
        $('#mydiv').html(data);
    });
});

(Note that this is freehand code, I haven't tested it. But you get the idea.)

这篇关于在另一个html里面查看html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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