是否可以将div从网站复制到另一个网站? [英] Is it possible to copy a div from a website to another?

查看:61
本文介绍了是否可以将div从网站复制到另一个网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将div从一个站点复制到另一个站点?管理许多网站我需要复制一些静态代码部分(例如通用页脚),而不必在每个网站上都进行更改.我一直在使用jQuery,但我对.clone()有所了解,但我不知道如何使它从一个站点到另一个站点都能正常工作

is it possible to copy a div from a site to another? Managing many websites I need to copy some static portions of code (e.g. a common footer) without having to go on every website and change it. I was looking to use jQuery, I know about the .clone() but I don't know how to make it work from a site to another

推荐答案

我正在四处寻找答案,并找到了这段代码.如果你不能使用iframe.

I was surfing around looking for an answer and found this code. If you can't use an Iframe.

作为替代方案,您可以只使用一个简单的方法,并使用jQuery的加载"功能加载整个页面,然后仅提取所需的部分:

As an alternative, you could just use a simple and use the jQuery "load" function to load the whole page and pluck out just the section you want:

$('#target-div').load('http://www.mywebsite.com/portfolio.php #portfolio-sports');

您可能还需要做其他事情,并且最大的不同是内容将成为主页的一部分,而不是被隔离到单独的窗口中.

There may be other things you need to do, and a significant difference is that the content will become part of the main page instead of being segregated into a separate window.

这篇关于是否可以将div从网站复制到另一个网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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