我想设置我的 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>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();
关于javascript - window.open 样式使用 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21224676/