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

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

问题描述

  $('#divURLContent')

我使用jquery的行将内容加载到我的页面上的div上。 ).load(的 'http:// myurl');

问题是我正在加载的页面上的CSS覆盖了它加载到的页面上的CSS 。有没有办法来防止这种情况发生?

解决方案

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

您应该只关心在服务器中仅显示一堆HTML,而不使用head或body,或者选择要插入DIV的内容部分。 / p>

在你的情况中,你可以做的最简单的事情是:

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

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



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


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

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

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?

解决方案

It usually makes no sense to load a full page inside a 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');

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

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

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

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