ユーザーが自分の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の場合)。
21のFlash Player上:ここ
私は、Mac上のSafariとFirefoxで見ているかのスクリーンショットです:
サファリ(ズームのclientWidth値の変更)
Firefoxは
(値はズームにその変化は認められませんでした)
ユーザーが表示>ズーム>テキストサイズを大きくするメニューに行くとき。 htmlページのスケールが増加します。 Safariでは、クライアントの幅が増加します。 Firefoxではそうではありません。私はCtrl +マウスホイールを使用していないが、同じ結果のように聞こえる。私はデバイスのピクセル比率を見て、それが私のために変わるかどうかを見ていきます。 –
元の投稿にスクリーンショットを追加しました –
私は何を言いますか?私はgifを追加しました。それは私のFirefoxで動作します。私はサファリを持っていません。おそらくhtml/jsのタグを付けてhtml masochistに答える必要があります:P –