点击按钮调节网页字体大小

4个月前 (05-10 16:36)阅读回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值5294
  • 级别管理员
  • 主题1058
  • 回复2
楼主

这是一个手动调节网页字体大小特效,用户可手动调节页面上的字体大小,点击按钮即可实现,结合自己需求来修改即可。

<SCRIPT>
 <!--
var zoomRate = 20;
var maxRate = 500;
var minRate = 50;
var currZoom = 100;
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
//document.onkeypress = getKey;
//window.onload = initZoom;
function GetCookie(name){
if (document.cookie != "") {
zoomc = document.cookie.split("; ");
for (var i=0; i < zoomc.length; i++) {
                zoomv = zoomc[i].split("=");
                if (zoomv[0] == name) {
    return  unescape(zoomv[1]);
                }
}
}else{
return "";
}
}
function SetCookie(name,value){
document.cookie = name + "=" + escape (value)+";";
}
/*function GoZoom(contentid){
if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
document.all[contentid].style.zoom = GetCookie("zoomVal");
currZoom=GetCookie("zoomVal");
}
else{
document.all[contentid].style.zoom = '100%';
currZoom = '100%';
}
}*/
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
function zoomInOut(contentid, how) {
if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
document.all[contentid].style.zoom = GetCookie("zoomVal");
currZoom=GetCookie("zoomVal");
}
else{
document.all[contentid].style.zoom = '100%';
currZoom = '100%';
}
if (((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
return;
}
if (how == "in") {
document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)+zoomRate+'%';
}
else {
document.all[contentid].style.zoom = parseInt(document.all[contentid].style.zoom)-zoomRate+'%'
}
SetCookie("zoomVal",document.all[contentid].style.zoom);
showCurrZoom(contentid);
}
/*
function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
which2 = eventChooser;
var el=event.srcElement;
if ((el.tagName != "INPUT") && (el.tagName != "TEXTAREA"))
{
if(which == "+" )
zoomInOut('zoom', 'in');
else if(which == "-" )
zoomInOut('zoom', 'out');
}
}*/
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
function initZoom(contentid) {
if(GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
document.all[contentid].style.zoom = GetCookie("zoomVal");
currZoom=GetCookie("zoomVal");
}
else{
document.all[contentid].style.zoom = '100%';
currZoom = '100%';
}
showCurrZoom(contentid);
}
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
function showCurrZoom(contentid) {
    document.all['showZoom'].innerText = document.all[contentid].style.zoom;
}
 //-->
</SCRIPT>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<div id="zoom">
<div style="text-align:center">
  <h4>
  欢迎来到武鸣人
  </h4>
</div>
<div>
<div style="text-align:center" ><input type="button" value="放大(+)" onclick="zoomInOut('zoom','in')"/>          <span id="showZoom"></span>          <input type="button" value="缩小(-)" onclick="zoomInOut('zoom','out')"/></div><br/><div style="text-align:center"><br/>
<script type="text/javascript">initZoom("zoom");</script>
</div>
</div>
</div>


0
0
收藏0

本文来自武鸣人网站,转载请注明出处

本文地址:https://www.wuming.ren/a/961.html

回帖

点击按钮调节网页字体大小 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息