load js or php based on users screen size

后端 未结 4 546
刺人心
刺人心 2020-12-19 14:36

I have a couple of Swiffy (HTML5 SWF) animations which i only want to be loaded based on the users screen size!

iv found some JavaScript below which says it will loa

4条回答
  •  悲&欢浪女
    2020-12-19 15:08

    Change this:

    if(screen.Width>1400)
    

    to:

    if (screen.width > 1400)
    

    width property of the screen object should be lowercase.

    Also note that when JavaScript is executed ServerSide processing is ended, and your document.writes only output text instead of executable php codes, you can use the load method of the jQuery instead.

    Load data from the server and place the returned HTML into the matched element.

    if (screen.width > 1400) {
         $('#wrapper').load('/map/map4.php');
    } else {
         $('#wrapper').load('/map/map1.php');
    }
    

提交回复
热议问题