我正在研究我的响应式设计,但是在使用adsense方面遇到了麻烦.
我的广告应该出现在桌面设计上,而不是移动设计上.因此,只有在桌面上查看网站时,才应将广告代码放在html中.使用display:none可以使用css,但这是针对adsense TOS的,所以不是解决方案.
我认为可以使用像http://mobiledetect.net这样的PHP类,但我更喜欢检查浏览器宽度然后决定做什么.
Adsense有如下批准的示例,但我可以将其用于我的目标吗?
<script type="text/javascript">
google_ad_client = "ca-publisher-id";
width = document.documentElement.clientWidth;
google_ad_slot = "1234567890";
google_ad_width = 320;
google_ad_height = 50;
if (width > 500) {
google_ad_slot = "3456789012";
google_ad_width = 468;
google_ad_height = 60;
}
if (width > 800) {
google_ad_slot = "2345678901";
google_ad_width = 728;
google_ad_height = 90;
}
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Run Code Online (Sandbox Code Playgroud)
我希望有人能指出我正确的方向.
在我编写的程序中,我需要鼠标绝对位置在表单的左上角。我正在使用此代码:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "x: " & X & " - y: " & Y
End Sub
Run Code Online (Sandbox Code Playgroud)
当我使用此代码时,左上角的坐标为0,0。但是问题是,当我在表单中移动时,值太大了15倍。
这就是为什么我使用:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "x: " & X / 15 & " - y: " & Y / 15
End Sub
Run Code Online (Sandbox Code Playgroud)
这样可以给出正确的坐标,但是为什么我需要将其乘以15?我不确定该代码是否在其他系统上兼容。