Pregunta

Simple question. I cannot get a new opened window to use CSS.

var previewWindow = window.open();
$(previewWindow.document.body).append(data);

The data is just a stringbuilder generating html from our backend.

The problem is, I want the newly opened tab/window to use Twitter bootstrap, either CDN or use the file.

I cannot get it to work with, what I tought should be the solution

$(previewWindow.document.head).append('cdn or path goes here')

I cannot seem to find anyone else with this problem, or I need a lecture in Google.

head

As you can see, in the head the CDN is properly added. But the html isn't using any of the CSS.

¿Fue útil?

Solución

You're using protocol-relative URLs.

However, since you don't pass a URL to window.open(), it displays about:blank.

Therefore, it tries to load about://netdna.bootstrapcdn.com/..., which doesn't exist.

You should use absolute URLs that include a protocol.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top