第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在所有現(xiàn)代瀏覽器中檢測頁面縮放級別?

如何在所有現(xiàn)代瀏覽器中檢測頁面縮放級別?

富國滬深 2019-05-30 17:43:54
如何在所有現(xiàn)代瀏覽器中檢測頁面縮放級別?如何在所有現(xiàn)代瀏覽器中檢測頁面縮放級別?而這個螺紋在IE7和IE8中,我無法找到一個很好的跨瀏覽器解決方案。Firefox存儲頁面縮放級別以供將來訪問。在第一頁加載時,我能獲得縮放級別嗎?在我讀到的某個地方,當發(fā)生縮放更改時,它會工作后頁面被加載。有沒有辦法把'zoom'活動?我需要這個,因為我的一些計算是基于像素的,它們可能在縮放時波動。@TfL提供的修改樣本此頁面在縮放時提醒不同的高度值。[jsFiddle]<html>     <head>         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"/></script>     </head>     <body>         <div id="xy" style="border:1px solid #f00; width:100px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit.          Pellentesque sollicitudin tortor in lacus tincidunt volutpat. Integer dignissim imperdiet mollis. Suspendisse quis          tortor velit, placerat tempor neque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.          Praesent bibendum auctor lorem vitae tempor. Nullam condimentum aliquam elementum. Nullam egestas gravida elementum.           Maecenas mattis molestie nisl sit amet vehicula. Donec semper tristique blandit. Vestibulum adipiscing placerat mollis.</div>         <button onclick="alert($('#xy').height());">Show</button>     </body></html>
查看完整描述

3 回答

?
慕勒3428872

TA貢獻1848條經(jīng)驗 獲得超6個贊

對我來說,對于Chrome/Webkit,document.width / jQuery(document).width()不起作用。當我把窗戶變小,放大到我的網(wǎng)站上時,就出現(xiàn)了水平滾動條,document.width / jQuery(document).width()在默認縮放時不等于1。這是因為document.width包括視圖之外的部分文檔。

使用window.innerWidthwindow.outerWidth起作用了。由于某些原因,在Chrome中,外部寬度是用屏幕像素來測量的,而內(nèi)部寬度是用CSS像素來測量的。

var screenCssPixelRatio = (window.outerWidth - 8) / window.innerWidth;if (screenCssPixelRatio >= .46 && screenCssPixelRatio <= .54) {
  zoomLevel = "-4";} else if (screenCssPixelRatio <= .64) {
  zoomLevel = "-3";} else if (screenCssPixelRatio <= .76) {
  zoomLevel = "-2";} else if (screenCssPixelRatio <= .92) {
  zoomLevel = "-1";} else if (screenCssPixelRatio <= 1.10) {
  zoomLevel = "0";} else if (screenCssPixelRatio <= 1.32) {
  zoomLevel = "1";} else if (screenCssPixelRatio <= 1.58) {
  zoomLevel = "2";} else if (screenCssPixelRatio <= 1.90) {
  zoomLevel = "3";} else if (screenCssPixelRatio <= 2.28) {
  zoomLevel = "4";} else if (screenCssPixelRatio <= 2.70) {
  zoomLevel = "5";} else {
  zoomLevel = "unknown";}


查看完整回答
反對 回復 2019-05-30
  • 3 回答
  • 0 關注
  • 564 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號