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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745298857a4621310.html
评论列表(0条)