2017-04-11 11 views
3

ユーザーが自分のWebページを拡大表示しているかどうかを確認しようとしていますが、そのうちの1つを決定するために利用できるプロパティがいくつかあるようです。 browserZoomFactor。私が試したことは、価値を変えることではありません。常に1です。私はまた、HTMLラッパーページで拡張するbrowserzoomとnoScaleに設定しましたブラウザの拡大率をどのようにするには?

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 

       minWidth="955" minHeight="600" 
       applicationComplete="application1_applicationCompleteHandler(event)"> 

    <fx:Script> 
     <![CDATA[ 
      import mx.events.FlexEvent; 

      protected function getZoomInfo():void { 
       var clientWidth:int; 
       var scaleFactor:Number 

       if (ExternalInterface.available) { 
        ExternalInterface.marshallExceptions = true; 
        clientWidth = ExternalInterface.call(string, ExternalInterface.objectID); 
        scaleFactor = Number(Number(stage.stageWidth/clientWidth).toFixed(1)); 
       } 

       zoomFactorLabel.text = ""; 
       zoomFactorLabel.text += "Client width: "+clientWidth + "\n"; 
       zoomFactorLabel.text += "Stage width: "+stage.stageWidth + "\n"; 
       zoomFactorLabel.text += "Calculated Scale factor: "+scaleFactor + "\n"; 
       zoomFactorLabel.text += "Browser Zoom factor: "+stage.browserZoomFactor + "\n"; 
       zoomFactorLabel.text += "Content Scale Factor: "+stage.contentsScaleFactor + "\n"; 
       zoomFactorLabel.text += "DPI: "+applicationDPI; 
      } 

      protected function application1_applicationCompleteHandler(event:FlexEvent):void { 
       stage.addEventListener(Event.BROWSER_ZOOM_CHANGE, browserZoomChange); 
       getZoomInfo(); 
      } 

      protected function browserZoomChange(event:Event):void { 
       trace("Zoom changed"); 
       zoomFactorLabel.text = "Zoom changed"; 
      } 

     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <fx:String id="string"><![CDATA[ 
function(clientId) { 
    var clientWidth = document.getElementById(clientId).clientWidth; 
    return clientWidth; 
} 
     ]]></fx:String> 
    </fx:Declarations> 

    <s:TextArea id="zoomFactorLabel" horizontalCenter="0" verticalCenter="-60"/> 
    <s:Button label="check browser zoom" click="getZoomInfo()" horizontalCenter="0" verticalCenter="30"/> 

</s:Application> 

:ここ

は、私が使用しているコードです。そして、どちらのオプションも何もしていないようです。ブラウザズームはデフォルトで有効になっているはずです。

swfオブジェクトのクライアントの幅を手作業で取得すると、ステージの幅と比較してスケールファクタを取得できますが、Firefox(Macの場合)では動作しません(Macの場合)。

  • アドビブログpostブラウザズームファクタ。
  • リリースnotes UPDATE

21のFlash Player上:ここ
私は、Mac上のSafariとFirefoxで見ているかのスクリーンショットです:

サファリ(ズームのclientWidth値の変更)
Safari

Firefoxは
(値はズームにその変化は認められませんでした)

答えて

0

ユーザーのCtrl + MouseHweleled htmlページの後にswfのサイズを取得しようとしていますか?私はあなたがページ全体をズームしている場合、clientWidthが変更されるとは思わない。 window.devicePixelRatioを試しましたか?

私は、ページのサイズを決定して苦労してきたし、それはあなたがあなたのページが

function printDispSettings(){ 
    t = ""; 
    t += "wins: " + (w===window) + "\n"; 
    w = window; 
    t += "Hello\n"; 
    t += "screen:  " + screen.width +  " x " + screen.height + "\n"; 
    t += "screen.avail: " + screen.availWidth + " x " + screen.availHeight + "\n"; 
    t += "screen.aTL: " + screen.availTop + " x " + screen.availLeft + "\n"; 
    t += "screen.TL: " + screen.top + " x " + screen.left + "\n"; 
    t += "pixDepth: " + screen.pixelDepth + "\n"; 
    t += "colDepth: " + screen.colorDepth + "\n"; 
    t += "pixRatio: " + window.devicePixelRatio + "\n"; 
    t += "win.Inner: " + window.innerWidth + " x " + window.innerHeight + "\n"; 
    t += "win.Outer: " + window.outerWidth + " x " + window.outerHeight +"\n"; 
    //t += "win.Inner: " + window.innerWidth + " x " + window.innerHeight + "\n"; 
    t += "win.TopLeft: " + window.scrollX + " x " + window.scrollY +"\n"; 
    t += "F " + c + "\n"; 
    t = repStr(t,10); 
    //document.writeln("<pre>" + s + "</pre>"); 
    //p.innerHTML = s; 
} 

をズームするときも、あなたがscrollWidth/Height代わりのclientWidth /高さ

を取得したいことがあり変える唯一のプロパティのように見えます

更新 - 私のFirefoxで動作します: enter image description here

+0

ユーザーが表示>ズーム>テキストサイズを大きくするメニューに行くとき。 htmlページのスケールが増加します。 Safariでは、クライアントの幅が増加します。 Firefoxではそうではありません。私はCtrl +マウスホイールを使用していないが、同じ結果のように聞こえる。私はデバイスのピクセル比率を見て、それが私のために変わるかどうかを見ていきます。 –

+0

元の投稿にスクリーンショットを追加しました –

+0

私は何を言いますか?私はgifを追加しました。それは私のFirefoxで動作します。私はサファリを持っていません。おそらくhtml/jsのタグを付けてhtml masochistに答える必要があります:P –

関連する問題