仅在某些屏幕分辨率下包括php文件 [英] include php file only at certain screen resolutions

查看:99
本文介绍了仅在某些屏幕分辨率下包括php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对自适应设计的adsense遇到了问题.我发现的一种解决方案是,如果窗口大小不够大,则根本不加载它们.所以我想我会用广告代码,容器等创建一个单独的php文件,然后将其包含在页面上.但是,我不能弄清楚如何仅在窗口宽度为720px或更高的情况下包括该文件,否则不包括此文件. 也许,可以以某种方式使用javascript,但不确定如何将其与所有dom和php一起使用.

I'm having issues with adsense on responsive design. One solution I found is to not load them at all if window size is not big enough. So I thought I would create a separate php file with advertisement code, container etc... and than include it on a page. However, I can't figure out how to only include this file if, lets say, window width is 720px or above, else don't include this file. Perhaps, javascript can be used some way, not sure how it will work with all the dom and php includes though.

推荐答案

您可以尝试以下方法:

<script language=javascript>
    if (screen.width >= 720 ) 
         $('#place_holder_div').load('file_from_server.php');
</script>

此处#place_holder_div是html文件中的div.语法为Jquery,但是如果愿意,您当然可以使用普通的javascript.该代码查看屏幕宽度,如果大于720像素,则将php文件file_from_server.php(将包含您的广告)加载到占位符div中.

Here #place_holder_div is a div in your html file. The syntax is Jquery but of course you can use plain javascript if you wish. The code looks at the screen width and if greater than 720 pixels, loads the php file file_from_server.php (which will contain your ad) into the placeholder div.

这篇关于仅在某些屏幕分辨率下包括php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆