javascript - window.open 样式使用 css

标签 javascript html 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>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/

相关文章:

performance - Linux 上 Firefox 的 Canvas2D 性能不佳

javascript - 从 url 隐藏提交类型输入值

html - 如何将页脚定位在页面底部并在内容增加时将其推到内容下方

javascript - 从具有嵌套数组的对象中删除项目

javascript - 正则表达式 - 只允许英文(小写或大写)、数字、特殊字符

javascript - 在 Javascript Text Typer Effect 中需要帮助

javascript - Div 元素不会占用整个空间

html - 修复图像在页面左侧、中心和右侧的位置,但也具有响应性

javascript - 如何在 Angular Js 中使用 name 或 id 属性验证表单

javascript - 将 PHP 字符串变量发送到 Javascript 字符串变量