javascript - media queries image file name change on screen size -


I am using media queries on one site, but considering the download of a large file, I am taking only 3g games to download on an iPhone.

Is it possible to use jquery to change a file name (i.e. background-jpg to background- .phone / netbook / ipad maybe even using media queries.

< P> It seems that it should be possible in my head .. It would be great if anyone can work out of there: - D

thanks in advance

stu < / P>

I have found this code to find the screen size

  $ (document) .r Eady (function () (if ((screen.width> = 1024) & amp; amp; amp; amp; (screen.height> = 768)) {Warning ('Screen size: 1024x600 or larger' ); $ ("Link [rel = stylesheet]: not (: first)"). Attr ({href: "detect1024.css"}) Other} {alerts ('Screen size: can be 1024x768, 800x600? '); $ ("Link [rel = stylesheet]: not (: first)"). Attr ({href: "detect800.css"}}}}};  

and I got this script which I think is adding text to the file

  $ ('rollover'). Hover (function () (/ when we use "roll on" var t = $ (This); T.attr ('src', t.attr ('src'), change the source of the input image. / ([[^.] *). (. *) /, "$ 1-over. $ 2") );}, Function () {var t = $ (this); T.attr ('src', t.attr ('src'). Mobile ',' ')); });  

Any ideas how can I add two ??

Something like -

  $ (document) .ready (function () {if ((screen.width> = 1024) & amp; amp; Screen.height> = 768)) {var t = $ (this); t.atter ('src', t.attr ('src') .replace ('- mobile', ''))});  

but do not know how to fix syntax errors

Or maybe - still the syntax error has ended, however

  $ (Document) .ready (function () {if ((screen.width> = 1024) & amp; amp; (screen> Height> 768)) {var re = new RegExp ("(. +) Back to the file namespace (again, "$ 1. $ 2")}}  

This is possible, and is not difficult to obtain. But due to simplicity, why not use something Enter:

  $ (document) .ready (function () (if ((screen.width = lt; = 960) & amp; amp; amp; amp; (.high & lt; = 640) ) $$ ("#added"). AddClass ("iphone");}};  

In this way, when the browser is equal to or below 960x640 (iPhone 4 resolution) Detects a resolution, it will automatically add a range of "iphone" to any element you specify. This body can be tags, a custom ID and so on.

You only need to do that which specifies a different background image than the square "iPhone".

Simple.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -