Jquery加载页面覆盖我的CSS [英] Jquery to load a page overides my CSS

查看:97
本文介绍了Jquery加载页面覆盖我的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery行将内容加载到我的页面上的div

I'm using the line of jquery to load content into a div on my page

$('#divURLContent').load('http://myurl');

问题是我加载页面上的CSS会覆盖加载到页面上的CSS 。是否有办法防止这种情况发生?

The problem is the CSS on the page I am loading overrides the CSS on the page it is loaded into. Is there a way to prevent this from happening?

谢谢。

推荐答案

p>在DIV中加载一个完整的页面通常是没有意义的。

It usually makes no sense to load a full page inside a DIV.

你应该在服务器中只渲染一堆HTML, ,或选择要在DIV中插入的内容部分。

You should take care of rendering only a bunch of HTML in the server, without head or body, or select the part of content that you want to insert in the DIV.

在您的情况下,您可以做的最简单的事情是:

In your case, the most simple thing you can do is:

$('#divURLContent').load('http://myurl body');

这将在DIV中只放入加载页面的body标签内的内容。

That will put in the DIV only the content inside the body tag of the loaded page.

查看 http://api.jquery.com/load加载页面片段以获取更多信息。

Look at http://api.jquery.com/load "Loading Page Fragments" for more information.

这篇关于Jquery加载页面覆盖我的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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