I load my content with .load() with this function:
$(document).ready(function(){
$("nav a").click(function () {
$("#main-content").load($(this).attr("href") + " #content > *");
return false;
开发者_如何学JAVA});
});
index.php contains the style and scripts.
The loaded content just contains the content in a div without head, body or styles.
Problems:
- IE8 doesn't load styles & this function doesn't work:
$(document).ready(function() {
if ($(window).width() < 630) {
$('aside').each(
function(){
$(this).parents('article').find('h2').after(this);
}
);
}
if ($(window).width() > 630) {
$('aside').each(
function(){
$(this).parents('section').after(this);
}
);
}
});
$(window).bind('resize', function(){
if ($(window).width() < 630) {
$('aside').each(
function(){
$(this).parents('article').find('h2').after(this);
}
);
}
if ($(window).width() > 630) {
$('aside').each(
function(){
$(this).parents('section').after(this);
}
);
}
});
I already tried to fix it like the other scripts with:
$(document).ajaxComplete(function(){ });
..but it didn't work.
Any help is very apprechiated.
Load the CSS explicitly using <link>
, and use $.getScript()
to load and execute the javaScript file.
Is aside
a class?
Then you'll have to use
$('.aside').each(
instead of
$('aside').each(
.
The same goes for article
and section
.
I figured out the problem: It's because of the HTML5 elements I use on the page. With HTML5shiv it's no problem to get them running on the page generally but IE won't catch them on loaded content via .load().
Here's a topic going on about that already.
How to "enable" HTML5 elements in IE 8 that were inserted by AJAX call?
innershiv is already a solution:
http://css-tricks.com/6869-html5-innershiv/
EDIT: But still having a problem with the named functions.
精彩评论