my code stock.com

daniel3d

jQuery Change the CSS link on diffident browser size
by daniel3d

Change the CSS link on diffident browser size.
Need jQuery.js to run !!!

Snippet options

Download: Download snippet as jquery-change-the-css-link-on-diffident-browser-size.html.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<!--******************** BROWSER SIZE CSS CHANGE **********************-->

<!-- LINK tag that the JavaScript Change when detect the width of
the browser [ /narrow.css,  /medium.css, /wide.css ] PUT IN THE <HEAD> TAG.
-->
<link id="size-stylesheet" rel="stylesheet" type="text/css" href="" />
<!-- END OF LINK TAG -->

<!-- START OF THE JAVASCRIPT
*/ PUT IN HEAD OF THE PAGE OR IN external.JS
-->
<script type="text/javascript">
function adjustStyle(width) {
    width = parseInt(width);
    if (width < 701) {
        $("#size-stylesheet").attr("href", "css/narrow.css");
    } else if ((width >= 701) && (width < 1920)) {
        $("#size-stylesheet").attr("href", "css/medium.css");
    } else {
       $("#size-stylesheet").attr("href", "css/wide.css");
    }
}

$(function() {
    adjustStyle($(this).width());
    $(window).resize(function() {
        adjustStyle($(this).width());
    });
});

</script>
<!-- END OF THE JAVASCRIPT -->
<!--******************** BROWSER SIZE CSS CHANGE **********************-->

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.