re-rendering html in a div to a new browser window
I would like to take all my <div>
's in a parent <div>
and re-render the contents into a new broswer window. Can anyone make any suggestions? I'm 开发者_JS百科using jQuery and .NET.
Get all divs in the markup.
var markupData = $("#names").html();
Empty div.
$("#names").empty();
open new window displaying markupData.
???
How about:
var html = $("#names").html();
var my_window = window.open("", "mywindow1", "width=350,height=150");
$(my_window.document).find("body").html(html);
Using window.open
. Keep a reference to the window you just created and set its HTML.
Example: http://jsfiddle.net/A72TH/
If you wanted to append a stylesheet containing CSS rules for the blank page, you could write something like this:
$(my_window.document)
.find("head")
.append("<link rel='stylesheet' href='styles.css' />");
Sounds like you want to make an instance of a new window and then write to it with your data. Here is a helpful link for that:
http://www.javascripter.net/faq/writingt.htm
精彩评论