好的,所以我设置了这个html模板,允许我们在ipads上显示动画html广告。基本上它使用媒体查询来确定设备的宽度,然后(使用css)显示“肖像”或“横向”div。纵向和横向对两个房子的iframe进行划分,其中包含各自方向的广告。
我遇到的问题是,由于某种原因,使用Adobe Edge制作的广告在更改设备方向时不会恢复。我希望完成的是在设备的方向发生变化时强制整个html页面或iframe的内容进行刷新,从而重新获得广告的动画。
我的代码如下:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1, minimum-scale=1, maximum-scale=1" />
<link href="http://www.calgaryheralddigital.com/creative/ads/general/reset.css" rel="stylesheet" type="text/css" media="screen">
<link href="http://www.calgaryheralddigital.com/creative/ads/general/clickTags.css" rel="stylesheet" type="text/css" media="screen">
<!-- orientation handler -->
<style type="text/css" media="all and (min-width: 1px) and (max-width: 800px)">
#portrait{ display:block; }
#landscape{ display:none; }
</style>
<style type="text/css" media="all and (min-width: 800px) and (max-width: 1500px)">
#portrait{ display:none; }
#landscape{ display:block; }
</style>
</head>
<body>
<div id="landscape">
<div style="z-index:1; position:relative;">
<iframe src="http://www.calgaryheralddigital.com/creative/ads/client/filename.html" width="1024px" height="90px" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
<div id="bannerLand">
<a href="%cINSERT URL HERE">
<img src="http://www.calgaryheralddigital.com/creative/ads/general/trans.gif" width="1024" height="90"/>
</a>
</div>
</div>
<div id="portrait">
<div style="z-index:1; position:relative;">
<iframe src="http://www.calgaryheralddigital.com/creative/ads/client/filename.html" width="768px" height="90px" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
<div id="bannerPort">
<a href="%cINSERT URL HERE">
<img src="http://www.calgaryheralddigital.com/creative/ads/general/trans.gif" width="768" height="90"/>
</a>
</div>
</div>
</body>
</html>
提前感谢您的帮助!
答案 0 :(得分:2)
我实际上能够使用从另一个堆栈溢出问题中提取的一些代码来自行解决此问题: What is the best method of re-rendering a web page on orientation change?
var supportsOrientationChange = "onorientationchange" in window,
orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function() {
window.location.reload()
}, false);