الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[ تنبيه ] How to print multiple nested divs

بدأه HomeSick في 25 أغسطس 2010 · 3 رد · 548 مشاهدة · في قسم البرمجة بــ Javascript
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

could you please help me in this:

I have multiple divs something like this


<div id="div1">
<div id="div2">
<div id="div3">
....
</div>
</div>

I want JavaScript code to print div1 with all nested divs as well

I tried using the following code but it only print div1 content


var printContent = document.getElementById('div1');

var windowUrl = 'about:blank';

var uniqueName = new Date();

var windowName = 'Print' + uniqueName.getTime();

var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=200,height=200');

printWindow.document.write(printContent.innerHTML);

printWindow.document.close();

printWindow.focus();

printWindow.print();

printWindow.close();


so please tell me how to do such operation ??

#2

*- يحظر استخدام اللهجة العامية

*- أو كتابة الأسئلة باللغة الإنجليزية

*- أو كتابة الكلمات الإنجليزية بالعربية

====

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

#3
اقتباس
HomeSick كتب:

I have multiple divs something like this


<div id="div1">
<div id="div2">
<div id="div3">
....
</div>
</div>

I want JavaScript code to print div1 with all nested divs as well

I tried using the following code but it only print div1 content


var printContent = document.getElementById('div1');

var windowUrl = 'about:blank';

var uniqueName = new Date();

var windowName = 'Print' + uniqueName.getTime();

var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=200,height=200');

printWindow.document.write(printContent.innerHTML);

printWindow.document.close();

printWindow.focus();

printWindow.print();

printWindow.close();


so please tell me how to do such operation ??

could you please help me in this:

the code is running correctly

تم تعديل هذه المشاركة بواسطة Xacker في 25 أغسطس 2010 في 21:37

In bad state

#4

*- يحظر استخدام اللهجة العامية

*- أو كتابة الأسئلة باللغة الإنجليزية

*- أو كتابة الكلمات الإنجليزية بالعربية

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

مواضيع مشابهة