Insert javascript into local html using its CSS stylesheet?
Modifying a SnapPages theme, meaning I only have access to the CSS stylesheet. I would like to insert some javascript in the header of the site in order to use TypeKit for styling typography. Is there anyway to do that from开发者_运维百科 CSS?
Simple answer: No.
More complex answer: CSS doesn't have the ability to make any changes to your page and things included in a page either via:
<link rel="stylesheet" type="text/css" href="custom.css" />
// or
<style>
..
</style>
Can't be made to execute as script.
Though you can in a sense alter (some of) the contents of a page from CSS, its use is discouraged and it is not up to the task you want to handle.
From quir]{smode: "I feel that we shouldn't use the content declaration at all. It adds content to the page, and CSS is meant for adding presentation to the page, and not content. Therefore I feel that you should use JavaScript if you want to dynamically generate content. CSS is the wrong tool for this job."
Not to my knowledge, no.
I don't think there is, no.
The only thing coming even close is IE-Based CSS Expressions (examples here). It may even have been possible to import style sheets that way, but support was discontinued in IE8.
精彩评论