Skip to content Skip to sidebar Skip to footer

External Stylsheets In New Window

Goal: open a new window, insert elements, and then apply css style to the elements in the new window using an external style sheet. Problem: I can insert the element in the new win

Solution 1:

If you look in the address bar, the URL is not on your website (In Chrome, it's about:blank). The path to your stylesheet being relative, it is not found.

You can solve that by using the full, absolute URL:

link.setAttribute('href', 'http://example.org/stylesheets/my.css');

https://jsfiddle.net/3xhrnpsa/ (using bootstrap's CSS for the demo, which makes the text sans-serif)

Post a Comment for "External Stylsheets In New Window"