1

好的,所以我已经设置了这个 html 模板,它允许我们在 ipad 上显示动画 html 广告。本质上,它使用媒体查询来确定设备的宽度,然后(使用 css)显示“纵向”或“横向”div。纵向和横向 div 都包含 iframe,其中包含各自方向的广告。

我遇到的问题是,由于某种原因,使用 Adob​​e 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>

预先感谢您的帮助!

4

1 回答 1

2

实际上,我可以使用从另一个堆栈溢出问题中提取的一些代码自行解决此问题: 在方向更改时重新呈现网页的最佳方法是什么?

var supportsOrientationChange = "onorientationchange" in window,
    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

window.addEventListener(orientationEvent, function() {
    window.location.reload()
}, false);
于 2012-07-03T15:09:11.853 回答