简体   繁体   English

window.open 样式使用 css

[英]window.open Style using css

I would like to style my window.open,我想设计我的 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.这是我的 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>

How do I parse css styles in javascript?如何在 javascript 中解析 css 样式?

Check out this answer: https://stackoverflow.com/a/18758370/1060487看看这个答案: https : //stackoverflow.com/a/18758370/1060487

From the answer:从答案:

Build a complete HTML page in the opened window and reference your CSS-file there:在打开的窗口中构建一个完整的 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();

I face this issue a few days ago.几天前我遇到了这个问题。 My issue was different just to style the popup center.我的问题是不同的只是样式弹出中心。

Here is the code which works for me这是对我有用的代码

<a href="http://twitter.com/intent/tweet?text=[TWEET_CONTENT_GOES_HERE]" 
  onclick="window.open(this.href, 
  'twitterwindow', 
  `top=${(screen.height - 570)/2}, left=${(screen.width - 570)/2}, width=600, 
   height=300, resizable=1`); return false;">
   Tweet this
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM