これを試して:
$.ajax({
url: 'page-to-load.html',
success: function(data) {
// load the content of the other page into #ajax-div
$('#ajax-div').html(data);
// a RegEx pattern to grab the opening body tag
var pattern=new RegExp("<body.*>");
// grab the opening body tag
var bodyOpeningTag = pattern.exec(data)[0];
// remove everything we don't need ('<body ', '>' and quotes)
var bodyAttributesString = bodyOpeningTag.replace('<body ', '');
bodyAttributesString = bodyAttributesString.replace('>', '');
bodyAttributesString = bodyAttributesString.replace(/\"/g,'');
// split the string into a one dimensional array ('background=/images/about.jpg', 'leftmargin=20' etc)
var bodyAttributesArray = bodyAttributesString.split(' ');
// split each attribute item into a [attributename, value] array
var bodyAttributesArray2d = new Array();
for (var i = 0; i < bodyAttributesArray.length; i++) {
bodyAttributesArray2d[i] = bodyAttributesArray[i].split('=');
}
}
});
デモページはこちら:
jQuery - ajax で別のページを読み込み、本文の属性を取得する