根据用户负荷JS或PHP屏幕尺寸负荷、根据、用户、屏幕尺寸

2023-09-11 01:03:02 作者:言不由衷。

我有几个Swiffy(HTML5 SWF)动画,我只希望根据用户加载屏幕尺寸!

四,发现了一些JavaScript,低于该说,这将加载如果screnn大于1400,但它不工作!

 <脚本语言= JavaScript的>
如果(screen.Width> 1400)
{
    的document.write(< PHP的包括:('/地图/ map4.php');?>中);
}
其他
{
    的document.write(< PHP的包括:('/地图/ map1.php');?>中);
}
< / SCRIPT>
 

剂量任何一个知道的客场要做到这一点无论是与上面还是另辟蹊径?

感谢

解决方案

更​​改此:

 如果(screen.Width> 1400)
 

 如果(screen.width> 1400)
 
详解PHP的执行原理和流程

宽度屏幕的财产对象应该是小写。

另外请注意,在执行JavaScript的服务器端处理结束,和你的文件撰写唯一的输出文本,而不是可执行的PHP codeS,你可以使用负荷 jQuery的方法替代。

  

从服务器读取数据,然后将返回的HTML到匹配的元素。

 如果(screen.width> 1400){
     $('#包装)的负载('/地图/ map4.php');
} 其他 {
     $('#包装)的负载('/地图/ map1.php');
}
 

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 load if screnn bigger than 1400 but its not working!

<script language=javascript>
if(screen.Width>1400)
{
    document.write("<?php include('/map/map4.php');?>");
}
else
{
    document.write("<?php include('/map/map1.php');?>");
}
</script>

dose any one know of away to do this either with the above or another way?

thanks

解决方案

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');
}

 
精彩推荐
图片推荐