Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to CSS files across domains without mixed content warning in IE?

My sites run off a subdomain (yyy.example.com), but I'm required to include CSS files from the main domain (example.com). We run a CMS that doesn't let me do any server-side stuff during the preview stage, so I'm stuck sending a page over https that includes a CSS import to http. All my IE users get a mixed content warning because of this.

Is there any client side way for me to prevent this, other than maintaining separate security settings for the domain on every client machine?

like image 941
Dan Bowling Avatar asked Dec 24 '09 17:12

Dan Bowling


1 Answers

Make use of protocol-relative URL's in the CSS links.

Thus so

<link rel="stylesheet" type="text/css" href="//example.com/style.css">

instead of

<link rel="stylesheet" type="text/css" href="http://example.com/style.css">

It will automatically pick the protocol of the parent request, which should work fine for HTTPS as well.

like image 159
BalusC Avatar answered Nov 04 '22 00:11

BalusC