javascriptで新しいhtmlドキュメントを作成したいと思います。本文にはdiv(display:inline)を作成し、そこにpタグを作成します。次に、pタグ(innerHTML)にString(titleTagString)を挿入します。今私は知っている、それはdivが持っているoffsetwidthです。クロムコンソールは0と答えています... どこが故障ですか? ありがとう!Offsetwidth by new HTML Document
function titleTagTester(titleTagString) {
//Create new document
newDoc = document.implementation.createHTMLDocument('titleTagTester.html');
//Create var body from document
var body = newDoc.getElementsByTagName('body');
//Create div element with style and add to body of document
newDoc.body.innerHTML += '<div style="width:600px" display="inline" id="divId"></div>';
//Create p element with style and add to div of body of document
newDoc.getElementById('divId').innerHTML += '<p style="color:#1a0dab" "font-family:arial" font-size:18px;">' + titleTagString + '</p>';
//getwidth of div
return newDoc.getElementById("divId").offsetWidth;
}