I'm working on a project where the client wants to have existing pages dynamically loaded into a single page. That's no problem, but the styling is not working as it should when the pages are loaded as standalone files on the existing site. Is there a way to extract the CSS link from each page and have it dynamically applied to the viewer page?
Here's a copy of the function I wrote out to call the external pages into the viewer page:
$(function () {
$('a.dock-item2').click(function () { // click on an anchor with the dock-item2 class
$("#page").remove(); // remove what's in the viewer already
var href = $(this).attr('href'); // grab the external file path and name
$('<div id="page" />').load(href, function () { // create a new div and load
// the page content
$(this).hide() // just stuff to make a nice transition...
.appendTo('#viewer')
.fadeIn(1000);
});
return false;
})
});
I'd like to apply it strictly to the div in question... but maybe that isn't the best thing to do. Should I consider loading this stuff into an iframe instead? Maybe it's just Friday and I can't think rationally anymore.