loading external file with css intact?

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 $('
').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.

以上就是loading external file with css intact?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏