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();
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With