flash - Javascript: How to get Browser Zoom level using third party -


this question has answer here:

how browser zoom level in known browsers? new workaround how detect page zoom level in modern browsers?

the idea use flash or html5 canvas find solution.

for found 1 solution using flash.

you need create flash file javascript bridge this:

[swf(width='100',height='100')] public class sizehack extends sprite {     public function sizehack()     {         if(stage){             onaddtostage();         }         else{             addeventlistener(event.added_to_stage, onaddtostage);         }     }      protected function onaddtostage(event:event = null):void     {         removeeventlistener(event.added_to_stage, onaddtostage);          // security settings allow scripting between domains         security.allowdomain("*");         security.allowinsecuredomain("*");          // register javascript         externalinterface.addcallback("getsize", onsizerequet);          // stage scale mode must noscale         stage.scalemode = stagescalemode.no_scale;     }      private function onsizerequet():number     {         if(!stage){             return 0;         }         return stage.stageheight;     } } 

then in javascript:

<script type="text/javascript">     swfobject.registerobject("flashresizer", "10.0.0");      function getbrowserzoom()     {         return swfobject.getobjectbyid("flashresizer")             .getsize();     } </script>  <div id="flashresizerdiv" style="position: absolute; display: block; height: 100px; width: 100%; top: 0; left: 0;">     <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100" id="flashresizer">         <param name="movie" value="resizer.swf" />         <!--[if !ie]>-->             <object type="application/x-shockwave-flash" data="resizer.swf" width="100%" height="100">             <!--<![endif]-->             <a href="http://www.adobe.com/go/getflashplayer">                 <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="get adobe flash player" />             </a>             <!--[if !ie]>-->             </object>         <!--<![endif]-->     </object> </div> 

now when call getbrowserzoom() exact zoom of browser.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -