0

I'm working on a site for one of my friends... And I am using media query for the css, to target monitors, iPad and other tablets... For the interactivity, I'm using jquery 1.5...

The BIG QUESTION IS: - How can I make jQuery call multiple js files, depending on what resolution the viewer is using?

It would mean the World to me if somebody could help me out here...

Best Regards / Myung Ki

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • 2
    The question is: should you? Can't you just change the behaviour of your scripts, dependent on resolution or (more appropriately) browser window size? – Thomas Mar 13 '11 at 09:41

2 Answers2

0

My suggestion is to use one set of js files, but handle the screen sizes early on in your program. The most you'd want to do is to have different css files for each screen size; having one js file for each will turn out to be very difficult to manage.

You can use jQuery to get the window size and add the relevant classes to the body or html tag. E.g., for large screens > 1024px across, you may add extraWide to body. Then you can selectively format for wide screens with specific css like body.extraWide.

Also, in mobile devices, trap the onorientationchange event to reformat the layout based on the new orientation. You may have classes called portrait and landscape added to body to have different css rules for different orientations.

Stephen Chung
  • 14,497
  • 1
  • 35
  • 48
0

see How to get screen resolution of visitor in javascript and/or php?

Community
  • 1
  • 1
Toby Allen
  • 10,997
  • 11
  • 73
  • 124