admin管理员组文章数量:1419220
I am trying to use .load
so I can load an external page into a div on the current user's page. When I call .load
, does it load the content and then style it with the current stylesheet defined in that page? If not how would I go about doing that? Example;
<head>
<link ref="stylesheet" href="main.css"/>
</head>
<body>
<div class="section">
<h2>Say this div was loaded with .load after page loaded</h2>
</div>
</body>
If .section
was loaded via .load
, would the style be loaded of the current page and modify that div after it loaded or is it just the html that got loaded with no styling. If it is the latter, how would I style it without using <style>
tags?
I am trying to use .load
so I can load an external page into a div on the current user's page. When I call .load
, does it load the content and then style it with the current stylesheet defined in that page? If not how would I go about doing that? Example;
<head>
<link ref="stylesheet" href="main.css"/>
</head>
<body>
<div class="section">
<h2>Say this div was loaded with .load after page loaded</h2>
</div>
</body>
If .section
was loaded via .load
, would the style be loaded of the current page and modify that div after it loaded or is it just the html that got loaded with no styling. If it is the latter, how would I style it without using <style>
tags?
- 1 Did you try it and see what happens? You could answer your own questions that way. – Brian Glaz Commented Jan 23, 2012 at 4:20
4 Answers
Reset to default 2Anytime you alter the DOM in a way that causes a redraw (such as adding visible elements to the DOM), each element is checked against all the rules in the CSS style-sheets.
So to answer your question directly. Yes, the styles will be added to elements that are added to the DOM at anytime.
If the css is available on the page which contains section
div then the styles will be applied after load
renders the content. Also if the styles are part of the load
response then also it will be rendered with styles applied.
If the styles are not available on the page and also you are not getting it in the load response then you have to explicitly get it using ajax or adding a link tag with appropriate stylesheet url into the page.
Your style of the current page will apply to the content loaded via .load
You can specify CSS in your main .css file, so when DOM is added, styles are taken from the main CSS file.
本文标签: javascriptJQuery load page into div with stylesStack Overflow
版权声明:本文标题:javascript - JQuery load page into div with styles - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745298856a2652246.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论