使用CSS的window.open样式 [英] window.open Style using css

查看:1027
本文介绍了使用CSS的window.open样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对我的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆