Hey i'm a bit late but i have some problem with my code..
function Orientation()
{
if ( (window.orientation == 0) || (window.orientation == 180) )//portrait
{
Paysage.style.visibility = "hidden";
Portrait.style.visibility = "visible";
mraid.removeEventListener("stateChange", mraidIsReady);
mraid.removeEventListener("orientationchange", mraidIsReady);
mraid.addEventListener("orientationchange", Orientation);
mraid.addEventListener("stateChange", Orientation);
//var video = document.getElementById("video");
//video.pause();
}
if ( (window.orientation == 90) || (window.orientation == -90) )//paysages
{
Portrait.style.visibility = "hidden";
Paysage.style.visibility = "visible";
mraid.removeEventListener("stateChange", mraidIsReady);
mraid.removeEventListener("orientationchange", mraidIsReady);
mraid.addEventListener("orientationchange", Orientation);
mraid.addEventListener("stateChange", Orientation);
//var video = document.getElementById("video");
//video.play();
//overlayObj.style.visibility = "";
//var video = document.getElementById("video");
//video.play();
}
}
function doReadyCheck()
{
if (mraid.getState() == 'loading')
{
mraid.addEventListener("orientationchange", Orientation);
mraid.addEventListener("stateChange", Orientation);
}
else
{
mraid.addEventListener("orientationchange", Orientation);
mraid.addEventListener("stateChange", Orientation);
}
}
doReadyCheck();
</script>
My EvetListener Always work while the loading but after it it wont work anymore ...
By the way i have a code working on IOS to block the orientation in landscape but it dont work on Android why ?
Thanks ! :)
I noticed few problems with your code
<script src="mraid.js"></script>,most probably it is since you have not pasted the whole code within script tag.mraid.addEventListener("orientationchange", Orientation);then while removing you shall callmraid.removeEventListener("orientationchange", Orientation);and notmraid.removeEventListener("orientationchange", mraidIsReady);Fifth, Not all mraid complaint SDK's support orientationchange, if your Ad SDK doesn't support that change event then listen to
window.addEventListener('orientationchange',Orientation);
Here is the code