Autor | Zpráva | ||
---|---|---|---|
davchy Profil |
#1 · Zasláno: 19. 11. 2012, 20:02:58
Zdravím,
snažím se docílit, aby byl nastaven rozměr objektu dle rozměru pracovní plochy prohlížeče. V Chrome a Firefoxu následující řešení funguje, ale v IE ne. Nejsem v tomto kovaný, můžete mi prosím říct kde je chyba? <!--[if !IE]>--><object type="application/x-shockwave-flash" data="http://media.goodgamestudios.com/games/ranch/goodgameranch.swf" width="800" height="600" id="flashcontent"><param name="menu" value="false"><param name="wmode" value="window"><param name="allowscriptaccess" value="always"><param name="allowFullScreen" value="true"></object><!--<![endif]--><!--[if IE]><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="600" id="flashcontent"><param name="movie" value="http://media.goodgamestudios.com/games/ranch/goodgameranch.swf"><param name="menu" value="false"><param name="wmode" value="window"><param name="allowscriptaccess" value="always"><param name="allowFullScreen" value="true"></object><![endif]--> <script type="text/javascript"> document.getElementById('flashcontent').style.height = (window.innerHeight || document.documentElement.clientHeight) + 'px'; document.getElementById('flashcontent').style.width = (window.innerWidth || document.documentElement.clientWidth) + 'px'; </script> Pro jistotu jsem testoval i: <script type="text/javascript"> document.getElementById('flashcontent').style.height = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || document.body.offsetHeight) + 'px'; document.getElementById('flashcontent').style.width = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || document.body.offsetWidth) + 'px'; </script> Mockrát díky |
||
suvel Profil |
#2 · Zasláno: 20. 11. 2012, 20:55:17
davchy:
Pro IE a Operu použij document.body.clientHeight document.body.clientWidth |
||
davchy Profil |
#3 · Zasláno: 21. 11. 2012, 11:07:26
To mě právě také nefungovalo. Nakonec jsem to podle nějakého tipu udělal takto:
<script type="text/javascript"> <!-- var viewportwidth; var viewportheight; // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth, viewportheight = window.innerHeight } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth, viewportheight = document.documentElement.clientHeight } // older versions of IE else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight } //--> </script> ........... <script type="text/javascript"> <!-- document.write('<object id="flashcontent" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+viewportwidth+'" height="'+viewportheight+'"> <param name="movie" value="http://media.goodgamestudios.com/games/ranch/goodgameranch.swf"/> <param name="allowFullScreen" value="true"> <param name="allowNetworking" value="all"> <param name="allowScriptAccess" value="always"> <param name="bgcolor" value="#72A90F"> <param name="menu" value="false"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <!--[if !IE]>--> <object id="_flashcontent" type="application/x-shockwave-flash" data="http://media.goodgamestudios.com/games/ranch/goodgameranch.swf" width="'+viewportwidth+'" height="'+viewportheight+'"> <param name="allowFullScreen" value="true"> <param name="allowNetworking" value="all"> <param name="allowScriptAccess" value="always"> <param name="bgcolor" value="#72A90F"> <param name="menu" value="false"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <!--<![endif]--> <div style="margin: 10% 50%;"> <a href="http://get.adobe.com/flashplayer/" target="_blank"><img src="http://wwwimages.adobe.com/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="get flash player" border="0"/></a> </div> <!--[if !IE]>--> </object> <!--<![endif]--></object>'); //--> </script> Takto mi to funguje. Teď se ještě zajímám o to, jestli by to nějakým lehkým způsobem šlo udělat tak, aby se velikost nastavovala dynamicky. To znamená když po načtení dojde ke změně velikosti okna prohlížeče. |
||
Chamurappi Profil |
#4 · Zasláno: 21. 11. 2012, 14:14:05
Reaguji na davchyho:
Proč nepoužiješ na nastavení rozměrů CSS s rozměry v procentech? |
||
davchy Profil |
#5 · Zasláno: 22. 11. 2012, 11:12:40
Protože šířku to správně nastaví, ale výšku ne. Ať nastavím do výšky jakoukoliv hodnotu v procentech, tak je to vždy jen proužek cca 250 px.
|
||
Joker Profil |
#6 · Zasláno: 22. 11. 2012, 11:18:53
davchy:
„Protože šířku to správně nastaví, ale výšku ne.“ By mělo stačit nastavit všem nadřízeným prvkům (včetně html a body) výšku 100%. |
||
Časová prodleva: 11 let
|
0