使用CSS的window.open样式 [英] window.open Style using css
问题描述
我想对我的window.open进行样式设置,
我目前在我的网页上有一些项目由于某个被解析的类而打开,在新窗口中打开指定的文本。
我想更改字体大小,字体和填充等。
这是我的javascript代码。
< script type =text / javascript>
$(。Show a)。click(function(){
var html = $(this).parent()。next(div.show-dialog)。html();
var my_window = window.open(,mywindow1,width = 750,height = 550);
$(my_window.document).find(body)。html(html );
});
< / script>
如何解析javascript中的CSS样式?
查看此答案: https://stackoverflow.com/a/18758370/ 1060487
从答案:
在打开的窗口和参考中构建一个完整的HTML页面您的CSS文件在那里:
var win = window.open('','printwindow');
win.document.write('< html>< head>< title>打印它!< / title>< link rel =stylesheettype =text / csshref =styles的CSS>< /头><身体GT;');
win.document.write($(#content)。html());
win.document.write('< / body>< / html>');
win.print();
win.close();
I would like to style my window.open,
I currently have some items on my webpage that open due to a certain class that is parsed, which there after opens the specified text in a new window.
I would like to change the font-size, font and padding etc.
Here is my javascript code.
<script type="text/javascript">
$(".Show a").click(function () {
var html = $(this).parent().next("div.show-dialog").html();
var my_window = window.open("", "mywindow1", "width=750,height=550");
$(my_window.document).find("body").html(html);
});
</script>
How do I parse css styles in javascript?
Check out this answer: https://stackoverflow.com/a/18758370/1060487
From the answer:
Build a complete HTML page in the opened window and reference your CSS-file there:
var win = window.open('','printwindow');
win.document.write('<html><head><title>Print it!</title><link rel="stylesheet" type="text/css" href="styles.css"></head><body>');
win.document.write($("#content").html());
win.document.write('</body></html>');
win.print();
win.close();
这篇关于使用CSS的window.open样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!