禁止页面缩放提示,ie浏览器提示

使用了新技术总会有兼容性问题,一般公司不考虑兼容性问题,但是还是出现诸如样式错乱、无法支持ie、缩放浏览器或屏幕设置比率非100%下的网页错位,作为开发者需要给出友好的提示,提高用户体验。

演示地址:https://sywsywsyw.github.io/noie-nozoom/

源码:https://github.com/sywsywsyw/noie-nozoom

==兼容ie8、不支持以下版本==
==兼容ie需要再服务器环境下打开== (可以使用http-server,live-server热更新服务)
==因为缩放之后所有内容也会缩放,所以需要把样式改为图片然后同步缩放图片==
==缩放图片规则为:最初尺寸除以当前比例 例如放大0.2倍就是 477/1.02==

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>不许ie,不许缩放</title>
<style>
.suiiewrap {
/* position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
z-index: 99999; */
}

.suiiebg {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .5;
background: #000;
}

.suiiemain {
position: fixed;
width: 480px;
min-height: 360px;
padding-bottom: 20px;
top: 50%;
left: 50%;
margin-left: -240px;
margin-top: -220px;
background: #fff;
overflow: hidden;
text-align: center;
z-index: 99999;
}

.spmhead {
width: 100%;
height: 50px;
background: #4878bd;
color: #fff;
position: relative;
}

.spmhclose {
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
position: absolute;
right: 0;
top: 0;
cursor: pointer;
}

.spmhcloseimg {
width: 25px;
height: 25px;
margin: 12.5px;
}

.spmcontent {
padding: 0 10%;
text-align: center;
}

.spmctitle {
text-align: center;
font-weight: bold;
margin-bottom: 8px;
font-size: 18px;
}

.spmctitledesc {
text-align: center;
font-weight: bold;
font-size: 16px;
}

.spmctips {
color: #8c8c8c;
font-size: 14px;
text-align: justify;
padding: 10px 0;
}

.spmctsp {
margin: 0;
padding: 0;
margin-bottom: 10px;
}

.spmctsblue {
color: #4878bd;
margin: 0 6px;
}

.spmcimg {
width: 40%;
margin: 20px;
}

.spmfnotips {
width: 200px;
height: 40px;
line-height: 40px;
text-align: center;
margin: 0 auto;
background: #4878bd;
font-size: 16px;
color: #fff;
cursor: pointer;
}


/* 缩放 */
.suizoomwrap {
/* position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
z-index: 99999; */
}

.suizoombg {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .5;
background: #000;
}

.suizoomcontent {
position: fixed;
width: 477px;
height: 412px;
top: 50%;
left: 50%;
margin-left: -237px;
margin-top: -206px;
background: #fff;
border-radius: 0;
overflow: hidden;
text-align: center;
z-index: 99999;
box-shadow: 0px 0px 13px 0px rgba(6, 193, 174, 0.15);
/* box-shadow: 1px 8px 25px 0px rgba(65, 115, 178, 0.1); */
}

.szcimg {
width: 100%;
height: 100%;
}

.szcclose {
width: 10.5%;
height: 12%;
text-align: center;
position: absolute;
right: 0;
top: 0;
cursor: pointer;
background: #000;
opacity: 0;
}

.szctips {
width: 42%;
height: 9.8%;
text-align: center;
margin: 0 auto;
background: #4878bd;
font-size: 16px;
color: #fff;
cursor: pointer;
position: absolute;
left: 29%;
bottom: 4.4%;
background: #000;
opacity: 0;
}
</style>
</head>

<body>
<!-- ie 提示 -->
<div class="suiiewrap">
<!-- <div class="suiiebg"></div> -->
<div class="suiiemain">
<div class="spmhead">
<div class="spmhtitle"></div>
<div class="spmhclose">
<img src="./close.png" alt="关闭" class="spmhcloseimg">
</div>
</div>
<div class="spmcontent">
<img src="./warn.png" alt="警告图片" class="spmcimg">
<div class="spmctitle">暂不支持IE类型浏览器</div>
<div class="spmctips">
<p class="spmctsp">1. IE浏览器下会出现样式错位等现象</p>
<p class="spmctsp">2. 请尝试更换其他浏览器,如360浏览器、QQ浏览器、谷歌浏览器......</p>
<p class="spmctsp">3. 双核浏览器请切换成极速内核</p>
</div>
</div>
<!-- <div class="spmcontent">
<img src="./warn.png" alt="" class="spmcimg">
<div class="spmctitle">页面缩放比例不正确</div>
<div class="spmctitledesc">可能会影响某些功能的正常使用</div>
<div class="spmctips">
<p class="spmctsp">1. 请尝试调整浏览器缩放比例为<span class="spmctsblue">100%</span>(快捷键 ctrl+0)</p>
<p class="spmctsp">2. 请尝试调整系统显示比例为<span class="spmctsblue">100%</span>(控制面板&nbsp;\&nbsp;显示 设置)</p>
</div>
</div> -->
<div class="spmfooter">
<div class="spmfnotips">不再提醒</div>
</div>
</div>
</div>

<!-- zoom 缩放 提示 -->
<div class="suizoomwrap">
<!-- <div class="suizoombg"></div> -->
<div class="suizoomcontent">
<img src="./zoomtips.png" alt="" class="szcimg">
<div class="szcclose">关闭</div>
<div class="szctips">不在提醒</div>
</div>
</div>
<script>
// 解决ie8 以下不支持 getElementsByClassName
function getElementsByClassName(className, root, tagName) { //root:父节点,tagName:该节点的标签名。 这两个参数均可有可无
if (root) {
root = typeof root == "string" ? document.getElementById(root) : root;
} else {
root = document.body;
}
tagName = tagName || "*";
if (document.getElementsByClassName) { //如果浏览器支持getElementsByClassName,就直接的用
return root.getElementsByClassName(className);
} else {
var tag = root.getElementsByTagName(tagName); //获取指定元素
var tagAll = []; //用于存储符合条件的元素
for (var i = 0; i < tag.length; i++) {
//遍历获得的元素
for (var j = 0, n = tag[i].className.split(' '); j < n.length; j++) {
//遍历此元素中所有class的值,如果包含指定的类名,就赋值给tagnameAll
if (n[j] == className) {
tagAll.push(tag[i]);
break;
}
}
}
return tagAll;
}
}
</script>
<script>
var u = navigator.userAgent || "";
var isMobAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isMobiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
console.log(isMobAndroid,isMobiOS)
// 弹框元素
var suiWrapObj = getElementsByClassName('suiiewrap')[0];
// 关闭按钮元素
var spmhCloseObj = getElementsByClassName('spmhclose')[0];
// 不再提醒元素
var noTipsObj = getElementsByClassName('spmfnotips')[0];
// 不在提醒 sessionStorage
var isNoIEVal = sessionStorage.getItem('isNoIE');

function suiWrapShow() {
// 如果点击过不在提醒
if (isNoIEVal != 'noietips') {
suiWrapObj.style.display = "block";
}
}

function suiWrapHide() {
suiWrapObj.style.display = "none";
}
// 判断是否是ie内核
var isIE = window.ActiveXObject || "ActiveXObject" in window;
function isIeFn() {
if (isIE) {
suiWrapShow();
} else {
suiWrapHide();
}
}
if( !isMobAndroid && !isMobiOS ){
isIeFn();
}
// 关闭提示
spmhCloseObj.onclick = function () {
suiWrapHide();
}
// 不再提醒
noTipsObj.onclick = function () {
sessionStorage.setItem('isNoIE', 'noietips');
suiWrapHide();
}

// 判断缩放比例 小于100 大于100 都为缩放
function detectZoom() {
var ratio = 0,
screen = window.screen,
ua = navigator.userAgent.toLowerCase();

if (window.devicePixelRatio !== undefined) {
ratio = window.devicePixelRatio;
} else if (~ua.indexOf('msie')) {
if (screen.deviceXDPI && screen.logicalXDPI) {
ratio = screen.deviceXDPI / screen.logicalXDPI;
}
} else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
ratio = window.outerWidth / window.innerWidth;
}

if (ratio) {
ratio = Math.round(ratio * 100);
}

return ratio;
};
// 缩放比例
var zoomVal = 100;
// 缩小比例
var zoomSmallVal = 0;
// 放大比例
var zoomBigVal = 0;
// 缩放弹框
var zoomWrapObj = getElementsByClassName('suizoomwrap')[0];
// 缩放关闭按钮
var zoomCloseObj = getElementsByClassName('szcclose')[0];
// 缩放不再提醒
var zoomTipsObj = getElementsByClassName('szctips')[0];
// 缩放内容
var zoomContentObj = getElementsByClassName('suizoomcontent')[0];
// 缩放内容css
var zoomCotentVal = {
width: 477,
height: 412,
marginLeft: 237,
marginTop: 206
}
// 不在提醒 sessionStorage
var isNoZoomVal = sessionStorage.getItem('isNoZoom');
zoomVal = detectZoom();
noZoomShowOrHide();
if (!isIE) {
window.addEventListener('resize', function () {
zoomVal = detectZoom();
noZoomShowOrHide();
})
}
// 控制nozoom弹框显示隐藏
function noZoomShowOrHide() {
var u = navigator.userAgent || "";
var isMobAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isMobiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if( isMobAndroid || isMobiOS ){
suiWrapHide();
zoomWrapObj.style.display = "none";
return;
}
if (isIE) {
zoomWrapObj.style.display = "none";
return;
}
console.log(zoomVal)
var zoom100Val = zoomVal / 100;
zoomCotentVal = {
width: 477 / zoom100Val,
height: 412 / zoom100Val,
marginLeft: 237 / zoom100Val,
marginTop: 206 / zoom100Val,
}
console.log(zoomBigVal, zoomSmallVal, zoom100Val)
console.log(zoomCotentVal)
if (zoomVal != 100) {
if (isNoZoomVal != 'nozoomtips') {
zoomWrapObj.style.display = "block";
}
} else {
zoomWrapObj.style.display = "none";
}

zoomContentObj.style.cssText = "width: " + zoomCotentVal.width + "px;height:" + zoomCotentVal.height +
"px;margin-left:-" + zoomCotentVal.marginLeft + "px;margin-top:-" + zoomCotentVal.marginTop + "px;"
}
zoomCloseObj.onclick = function () {
zoomWrapObj.style.display = "none";
}
zoomTipsObj.onclick = function () {
sessionStorage.setItem('isNoZoom', 'nozoomtips');
zoomWrapObj.style.display = "none";
}
</script>
</body>

</html>
```<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>不许ie,不许缩放</title>
<style>
.suiiewrap {
/* position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
z-index: 99999; */
}

.suiiebg {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .5;
background: #000;
}

.suiiemain {
position: fixed;
width: 480px;
min-height: 360px;
padding-bottom: 20px;
top: 50%;
left: 50%;
margin-left: -240px;
margin-top: -220px;
background: #fff;
overflow: hidden;
text-align: center;
z-index: 99999;
}

.spmhead {
width: 100%;
height: 50px;
background: #4878bd;
color: #fff;
position: relative;
}

.spmhclose {
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
position: absolute;
right: 0;
top: 0;
cursor: pointer;
}

.spmhcloseimg {
width: 25px;
height: 25px;
margin: 12.5px;
}

.spmcontent {
padding: 0 10%;
text-align: center;
}

.spmctitle {
text-align: center;
font-weight: bold;
margin-bottom: 8px;
font-size: 18px;
}

.spmctitledesc {
text-align: center;
font-weight: bold;
font-size: 16px;
}

.spmctips {
color: #8c8c8c;
font-size: 14px;
text-align: justify;
padding: 10px 0;
}

.spmctsp {
margin: 0;
padding: 0;
margin-bottom: 10px;
}

.spmctsblue {
color: #4878bd;
margin: 0 6px;
}

.spmcimg {
width: 40%;
margin: 20px;
}

.spmfnotips {
width: 200px;
height: 40px;
line-height: 40px;
text-align: center;
margin: 0 auto;
background: #4878bd;
font-size: 16px;
color: #fff;
cursor: pointer;
}


/* 缩放 */
.suizoomwrap {
/* position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
z-index: 99999; */
}

.suizoombg {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .5;
background: #000;
}

.suizoomcontent {
position: fixed;
width: 477px;
height: 412px;
top: 50%;
left: 50%;
margin-left: -237px;
margin-top: -206px;
background: #fff;
border-radius: 0;
overflow: hidden;
text-align: center;
z-index: 99999;
box-shadow: 0px 0px 13px 0px rgba(6, 193, 174, 0.15);
/* box-shadow: 1px 8px 25px 0px rgba(65, 115, 178, 0.1); */
}

.szcimg {
width: 100%;
height: 100%;
}

.szcclose {
width: 10.5%;
height: 12%;
text-align: center;
position: absolute;
right: 0;
top: 0;
cursor: pointer;
background: #000;
opacity: 0;
}

.szctips {
width: 42%;
height: 9.8%;
text-align: center;
margin: 0 auto;
background: #4878bd;
font-size: 16px;
color: #fff;
cursor: pointer;
position: absolute;
left: 29%;
bottom: 4.4%;
background: #000;
opacity: 0;
}
</style>
</head>

<body>
<!-- ie 提示 -->
<div class="suiiewrap">
<!-- <div class="suiiebg"></div> -->
<div class="suiiemain">
<div class="spmhead">
<div class="spmhtitle"></div>
<div class="spmhclose">
<img src="./close.png" alt="关闭" class="spmhcloseimg">
</div>
</div>
<div class="spmcontent">
<img src="./warn.png" alt="警告图片" class="spmcimg">
<div class="spmctitle">暂不支持IE类型浏览器</div>
<div class="spmctips">
<p class="spmctsp">1. IE浏览器下会出现样式错位等现象</p>
<p class="spmctsp">2. 请尝试更换其他浏览器,如360浏览器、QQ浏览器、谷歌浏览器......</p>
<p class="spmctsp">3. 双核浏览器请切换成极速内核</p>
</div>
</div>
<!-- <div class="spmcontent">
<img src="./warn.png" alt="" class="spmcimg">
<div class="spmctitle">页面缩放比例不正确</div>
<div class="spmctitledesc">可能会影响某些功能的正常使用</div>
<div class="spmctips">
<p class="spmctsp">1. 请尝试调整浏览器缩放比例为<span class="spmctsblue">100%</span>(快捷键 ctrl+0)</p>
<p class="spmctsp">2. 请尝试调整系统显示比例为<span class="spmctsblue">100%</span>(控制面板&nbsp;\&nbsp;显示 设置)</p>
</div>
</div> -->
<div class="spmfooter">
<div class="spmfnotips">不再提醒</div>
</div>
</div>
</div>

<!-- zoom 缩放 提示 -->
<div class="suizoomwrap">
<!-- <div class="suizoombg"></div> -->
<div class="suizoomcontent">
<img src="./zoomtips.png" alt="" class="szcimg">
<div class="szcclose">关闭</div>
<div class="szctips">不在提醒</div>
</div>
</div>
<script>
// 解决ie8 以下不支持 getElementsByClassName
function getElementsByClassName(className, root, tagName) { //root:父节点,tagName:该节点的标签名。 这两个参数均可有可无
if (root) {
root = typeof root == "string" ? document.getElementById(root) : root;
} else {
root = document.body;
}
tagName = tagName || "*";
if (document.getElementsByClassName) { //如果浏览器支持getElementsByClassName,就直接的用
return root.getElementsByClassName(className);
} else {
var tag = root.getElementsByTagName(tagName); //获取指定元素
var tagAll = []; //用于存储符合条件的元素
for (var i = 0; i < tag.length; i++) {
//遍历获得的元素
for (var j = 0, n = tag[i].className.split(' '); j < n.length; j++) {
//遍历此元素中所有class的值,如果包含指定的类名,就赋值给tagnameAll
if (n[j] == className) {
tagAll.push(tag[i]);
break;
}
}
}
return tagAll;
}
}
</script>
<script>
var u = navigator.userAgent || "";
var isMobAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isMobiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
console.log(isMobAndroid,isMobiOS)
// 弹框元素
var suiWrapObj = getElementsByClassName('suiiewrap')[0];
// 关闭按钮元素
var spmhCloseObj = getElementsByClassName('spmhclose')[0];
// 不再提醒元素
var noTipsObj = getElementsByClassName('spmfnotips')[0];
// 不在提醒 sessionStorage
var isNoIEVal = sessionStorage.getItem('isNoIE');

function suiWrapShow() {
// 如果点击过不在提醒
if (isNoIEVal != 'noietips') {
suiWrapObj.style.display = "block";
}
}

function suiWrapHide() {
suiWrapObj.style.display = "none";
}
// 判断是否是ie内核
var isIE = window.ActiveXObject || "ActiveXObject" in window;
function isIeFn() {
if (isIE) {
suiWrapShow();
} else {
suiWrapHide();
}
}
if( !isMobAndroid && !isMobiOS ){
isIeFn();
}
// 关闭提示
spmhCloseObj.onclick = function () {
suiWrapHide();
}
// 不再提醒
noTipsObj.onclick = function () {
sessionStorage.setItem('isNoIE', 'noietips');
suiWrapHide();
}

// 判断缩放比例 小于100 大于100 都为缩放
function detectZoom() {
var ratio = 0,
screen = window.screen,
ua = navigator.userAgent.toLowerCase();

if (window.devicePixelRatio !== undefined) {
ratio = window.devicePixelRatio;
} else if (~ua.indexOf('msie')) {
if (screen.deviceXDPI && screen.logicalXDPI) {
ratio = screen.deviceXDPI / screen.logicalXDPI;
}
} else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
ratio = window.outerWidth / window.innerWidth;
}

if (ratio) {
ratio = Math.round(ratio * 100);
}

return ratio;
};
// 缩放比例
var zoomVal = 100;
// 缩小比例
var zoomSmallVal = 0;
// 放大比例
var zoomBigVal = 0;
// 缩放弹框
var zoomWrapObj = getElementsByClassName('suizoomwrap')[0];
// 缩放关闭按钮
var zoomCloseObj = getElementsByClassName('szcclose')[0];
// 缩放不再提醒
var zoomTipsObj = getElementsByClassName('szctips')[0];
// 缩放内容
var zoomContentObj = getElementsByClassName('suizoomcontent')[0];
// 缩放内容css
var zoomCotentVal = {
width: 477,
height: 412,
marginLeft: 237,
marginTop: 206
}
// 不在提醒 sessionStorage
var isNoZoomVal = sessionStorage.getItem('isNoZoom');
zoomVal = detectZoom();
noZoomShowOrHide();
if (!isIE) {
window.addEventListener('resize', function () {
zoomVal = detectZoom();
noZoomShowOrHide();
})
}
// 控制nozoom弹框显示隐藏
function noZoomShowOrHide() {
var u = navigator.userAgent || "";
var isMobAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isMobiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if( isMobAndroid || isMobiOS ){
suiWrapHide();
zoomWrapObj.style.display = "none";
return;
}
if (isIE) {
zoomWrapObj.style.display = "none";
return;
}
console.log(zoomVal)
var zoom100Val = zoomVal / 100;
zoomCotentVal = {
width: 477 / zoom100Val,
height: 412 / zoom100Val,
marginLeft: 237 / zoom100Val,
marginTop: 206 / zoom100Val
}
console.log(zoomBigVal, zoomSmallVal, zoom100Val)
console.log(zoomCotentVal)
if (zoomVal != 100) {
if (isNoZoomVal != 'nozoomtips') {
zoomWrapObj.style.display = "block";
}
} else {
zoomWrapObj.style.display = "none";
}

zoomContentObj.style.cssText = "width: " + zoomCotentVal.width + "px;height:" + zoomCotentVal.height +
"px;margin-left:-" + zoomCotentVal.marginLeft + "px;margin-top:-" + zoomCotentVal.marginTop + "px;"
}
zoomCloseObj.onclick = function () {
zoomWrapObj.style.display = "none";
}
zoomTipsObj.onclick = function () {
sessionStorage.setItem('isNoZoom', 'nozoomtips');
zoomWrapObj.style.display = "none";
}
</script>
</body>
</html>

图一是透明关闭按钮自己找一下昂就这句话后面呢关闭按钮
图二在这里插入图片描述
图三在这里插入图片描述

0%