0
htmlドキュメント(ブックの章)を取り、それをページに分けたい(それぞれがDIVの配列で、htmlコンテンツのページが含まれています。 DIV)。私は次のコードでDOMを歩いています(このサイトにあります)。ノードをクローンするときにスタイルを保持する方法
function walk(node, func)
{
func(node);
node = node.firstChild;
while (node)
{
walk(node, func);
node = node.nextSibling;
}
};
func関数はtestと呼ばれ、以下のとおりです。
function test(node)
{
var copy=node.cloneNode(false);
currentPageInArray.appendChild(copy);
//Test if we still fit
if($(currentPageInArray).height() <= maxPageHeight)
{
//All good
}
else
{
//We dont fit anymore
//Remove node that made us exceed the height
currentPageInArray.removeChild(copy);
createNewPage();
currentPageInArray.appendChild(copy); //into new page
}
}
マイページが正しく生成されます、しかし、私はクローン(true)をしようとすると、多くの要素が重複した複数回の取得などイタリック、ボールド、ヘッダ、などなどすべてのスタイルを失います。これをどうすれば解決できますか?前もって感謝します。
あなたのスタイルシートにコンテンツをスタイリングしていない理由はありますか? – user113716