jquery - How to detect window resize and then change the javascript file being added to the header? -


To find out the size of the screen I have this jQuery and then attach a file to the header based on sceen size Please.

var scriptSrc = ''; Var widow with = $ (window). With (); If (widowWidth> = 1024) scriptSrc = '/js/desktop.js'; If ((Widow Quarter <= 1023) & amp; (Widow Quarter = 768)) scriptSrc = '/js/tablet.js'; And if (widow with <= 767) scriptSrc = '/js/mobile.js'; Var script = document.createElement ('script'); Script.src = scriptSrc; Var head = document.getElementsByTagName ('head') [0]; Head.appendChild (script);

I have $ (window) with it Have tried to use Resetize (), but I am unable to extract the file that was originally added before resizing.

I have you to change my code and as you can see it will add a JS file based on the size of the screen, but I would also like to change the screen but would like to change it.

Thank you for your time!

What do I use here:

  $ (window) Tie ('resize', function (event) {// which you want to run here}};  

Just set a variable for the width and height of the window and check That's what they are inside this function.

When the screen resizes then with reloading the whole page to replace its javascript file ... I do not think it is possible. A job It may run all the javascript files in a file and just run different actions that write down any changes that make up the previous JavaScript function.

This clearly uses jQuery though. / P>


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -