Change value of 'meta' in link css after onload

0

I have a problem.

I'm trying to use asynchronous CSS loading to optimize my graphic elements.

In the <head> of my html I have several links of .css (example:)

<link id="cs1" rel="stylesheet" href="css/ZooCss.css" media="none" onload="cambiarMedia()"/>

The cambiarMedia() function is above the links:

<script type="text/javascript">
    function cambiarMedia() {
        if (document.getElementById("cs1").getAttribute('media') === 'none') {
            document.getElementById("cs1").setAttribute('media', 'all');
        }
    }
</script>

Basically what I want you to do is change the value from meta to all . The problems that I crash with:

  • Just like the function cambiarMedia Visual Studio throws me the following error:
  •   

    'ASP.default_aspx' does not contain a definition of cambiarMedia nor is    found any extension method cambiarMedia that accepts a    first argument of type 'ASP.default_aspx' (missing a directive    using or an assembly reference?)

  • If I solve this error, I would also like to transform the cambiarMedia function so that it is reusable for all CSS's. Not to rewrite it for each CSS ID.
  • Can you give me a hand with that please?

        
    asked by Oren Diaz 16.11.2017 в 22:18
    source

    1 answer

    1

    <link href="
    <link rel="stylesheet" href="" media="none"/>
    <link rel="stylesheet" href="" media="none"/>
    <link id="paraprobar" rel="stylesheet" href="" media="none"/>                                    
    answered by 16.11.2017 в 23:49