最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Moving the content of an DIV to another window with JavaScriptJQuery - Stack Overflow

programmeradmin0浏览0评论

I need to make an "Print product" feature on my emerce site and the print part i already figured it out ... windows.print

My problem is that I want to copy the entire content of DIV where I have all product specifications and photos to another window which after I can print it.

I have a link Print this product which when clicked, JQUERY must create the new window and also copy the entire product's DIV to this new window.

I have seen several approaches here and it only confused me so that's why I am posting this here.

Can someone please explain me with an example how to solve my problem.

Thank you.

I need to make an "Print product" feature on my emerce site and the print part i already figured it out ... windows.print

My problem is that I want to copy the entire content of DIV where I have all product specifications and photos to another window which after I can print it.

I have a link Print this product which when clicked, JQUERY must create the new window and also copy the entire product's DIV to this new window.

I have seen several approaches here and it only confused me so that's why I am posting this here.

Can someone please explain me with an example how to solve my problem.

Thank you.

Share Improve this question asked Jan 23, 2012 at 13:35 Arizona2014Arizona2014 1,3472 gold badges18 silver badges33 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 4

Just get the content and set it in the new place:

var w = window.open();
w.document.body.innerHTML = window.document.getElementById('print').innerHTML;

Here is demo

Well I think that this plugin of jquery might help you.

http://projects.erikzaadi./jQueryPlugins/jQuery.printElement/

发布评论

评论列表(0)

  1. 暂无评论