A quick solution based on document.write would be:
<script type="text/javascript"> if (/facebook\.com/.test(window.top.location.host)) { document.write('<link rel="stylesheet" type="text/css" href="stylefacebook.css" />'); } </script>
Or using dom:
<script type="text/javascript"> if (/facebook\.com/.test(window.top.location.host)) { var lnk = document.createElement('link'); lnk.type='text/css'; lnk.href='stylefacebook.css'; lnk.rel='stylesheet'; document.getElementsByTagName('head')[0].appendChild(lnk); } </script>
Or using jquery:
<script type="text/javascript"> if (/facebook\.com/.test(window.top.location.host)) { $('head:first').append('<link rel="stylesheet" type="text/css" href="stylefacebook.css" />'); } </script>
arnaud576875
source share