⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wm_scl_fnt.html

📁 有很多很实用的方法
💻 HTML
字号:
<!-- check for different collection -->
<html>

<head>
<title>scale_font</title>
<meta name="description"
content="Webmonkey Array Enhancements: JavaScript 1.2, which works only in Netscape 4.0, adds several fundamental methods to the array object. A few of these very useful methods are included here in a form that can be used by 3.0 browsers.">
<meta name="keywords"
content="javascript, dhtml, javascript, code, scripting, dynamic, developer resource, developer, development, web
development, design, code, geek, warez, free, new, latest, news, tools,
info, tutorials, how-to, builder, web builder, page builder, javascript, dhtml, javascript, code, scripting, dynamic, developer resource,
developer, development, web development, design, code, geek, warez, free,
new, latest, news, tools, info, tutorials, how-to, builder, web builder,
page builder">
</head>

<body BGCOLOR="#ffffff" TEXT="#000000" link="#0000ff" Vlink="#660099">
<!-- TOP AD BANNER -->
<a
href="../../../tppmsgs/msgs0.htm#73" tppabs="http://nsads.hotwired.com/event.ng/Type=click&ProfileID=176&RunID=4311&AdID=5612&GroupID=1&FamilyID=415&TagValues=13.25.156.159.169.174.177.181.182.183.184.185.196.197.198.199.200.208.213.333.349.389.401.411.436.526&Redirect=http://www.microsoft.com/sitebuilder/vinterdev/vionsbn.asp?30600vibeta"
TARGET="_top"><nobr>

<p></nobr></a> </p>

<table border="0" cellpadding="0" width="530" celspacing="0">
  <tr>
    <td><font size="3" color="#0000FF" face="宋体"><a
    href="../../../tppmsgs/msgs0.htm#52" tppabs="http://www.webmonkey.com.cn/design.html" target="_top">网页设计</a><a
    href="../../../tppmsgs/msgs0.htm#53" tppabs="http://www.webmonkey.com.cn/html.html" target="_top">/HTML文件</a><a
    href="../../../tppmsgs/msgs0.htm#32" tppabs="http://www.webmonkey.com.cn/dynamic_html.htm" target="_top">/动态HTML文件</a></font><a
    href="../../../tppmsgs/msgs0.htm#54" tppabs="http://www.webmonkey.com.cn/stylesheets.html"><font size="2" color="#0000FF"
    face="宋体">/Stylesheets</font></a><font size="3" color="#0000FF" face="宋体"><a
    href="../../../tppmsgs/msgs0.htm#55" tppabs="http://www.webmonkey.com.cn/graphics.html" target="_top">/图形与字体</a><a
    href="../../../tppmsgs/msgs0.htm#56" tppabs="http://www.webmonkey.com.cn/multimedia.html" target="_top">/多媒体</a></font><font
    size="2" color="#0000FF" face="宋体">&nbsp;</font></td>
  </tr>
  <tr>
    <td><a href="../../../tppmsgs/msgs0.htm#57" tppabs="http://www.webmonkey.com.cn/browsers.html" target="_top"><font size="3"
    color="#0000FF" face="宋体">浏览器</font></a><font size="2" color="#0000FF"
    face="宋体"><a href="../../../tppmsgs/msgs0.htm#58" tppabs="http://www.webmonkey.com.cn/java.html">/Java</a><a
    href="../../../tppmsgs/msgs0.htm#31" tppabs="http://www.webmonkey.com.cn/javascript.html">/JavaScript</a><a
    href="../../../tppmsgs/msgs0.htm#33" tppabs="http://www.webmonkey.com.cn/perl.html">/<nobr>Perl</nobr></font><font
    color="#0000FF" face="宋体">语言</font></a><nobr><font size="2" color="#0000FF"
    face="宋体"><a href="../../../tppmsgs/msgs0.htm#59" tppabs="http://www.webmonkey.com.cn/backend.html">/Backend</a><a
    href="../../../tppmsgs/msgs0.htm#60" tppabs="http://www.webmonkey.com.cn/e_business.htm">/</font><font size="3" color="#0000FF"
    face="宋体">电子商务</font></a></nobr></td>
  </tr>
  <tr>
    <td width="530"><br>
    <font face="宋体"><nobr><!-- TOP NAVIGATION and SPONSOR STUFF --> <font size="5"><a href="../../../tppmsgs/msgs0.htm#50" tppabs="http://www.webmonkey.com.cn/javascript/code/webmonkey.html"><b>webmonkey</b></a><a
    href="../../../tppmsgs/msgs0.htm#31" tppabs="http://www.webmonkey.com.cn/javascript.html">/javascript</a><a href="code.htm" tppabs="http://www.webmonkey.com.cn/javascript/code/code.htm">/code</a><a
    href="dhtml.htm" tppabs="http://www.webmonkey.com.cn/javascript/code/dhtml.htm">/</font><font size="4">DHTML</font></a></nobr></font></td>
  </tr>
  <tr>
    <td width="530"><font face="宋体" size="2">网猴的Javascript代码库收集了我们自己制作的代码、函数包、及网页编辑器功能扩展其<br>
    中既有通用目的的编码,也有用于特定用途的程序、以及一些你可以以来改善你的网页的<br>
    优秀设计思想。其中的代码你可以免费下载使用。</font></td>
  </tr>
</table>

<table CELLPADDING="3" CELSPACING="0" BORDER="0" width="532">
<!-- AUTHOR IMAGE -->
  <tr>
<!-- BUFFER -->
    <td rowspan="100" width="10"><font face="宋体"><img
    SRC="../../../static.wired.com/webmonkey/images/spacer.gif" tppabs="http://static.wired.com/webmonkey/images/spacer.gif" WIDTH="10" HEIGHT="1"></font></td>
    <td width="165" valign="middle" align="right" colspan="2"></td>
<!-- HEADLINE -->
    <td width="365" valign="middle"><font size="4" color="#ff3300" face="宋体"><br>
    </font><b><font color="#ff3300" face="宋体" size="5">网</font><font color="#ff3300"
    size="5">猴的文字比例缩放</font></b><font face="宋体"><br>
<!-- BYLINE -->    作者:<font color="#0000FF">Taylor</font></font></td>
  </tr>
<!-- SEE ALSO LINKS -->
  <tr>
    <td width="155" align="left" valign="top" bgcolor="#FFFFB5"><font face="宋体"><img
    SRC="../../../static.wired.com/webmonkey/images/spacer.gif" tppabs="http://static.wired.com/webmonkey/images/spacer.gif" WIDTH="155" HEIGHT="1"><br>
    <br>
    <font size="3"><b>Related Library Items</b></font><br>
    <font color="#ff3300">- - - - - - - - - -</font> <br>
    </font><font size="3"><b><a href="wm_chg_link_bh.html" tppabs="http://www.webmonkey.com.cn/javascript/code/wm_chg_link_bh.html">网猴的变换链接行<br>
    为(<font face="宋体">Change Link <br>
    Behavior</font>)</a></b></font><font face="宋体"><big><br>
    </big></font><font size="3">该<strong>行为</strong>能够使你改变<br>
    网页中一个或多个定<br>
    位链接将其指向不同<br>
    的<font face="宋体">URL</font>。</font><font size="2" face="宋体"><br>
    </font><p><font size="3"><a href="cookie.htm" tppabs="http://www.webmonkey.com.cn/javascript/code/cookie.htm"><b>网猴<font face="宋体">Cookies</font>集锦</b></a></font><font
    face="宋体"><br>
    </font><font size="3">这些函数可以大大简化你使用<font face="宋体">cookies</font>时<br>
    的麻烦。</font><font size="2"><br>
    </font><font face="宋体"><br>
    <br>
    </font></td>
<!-- BODY COPY -->
<!-- BUFFER -->
    <td width="10" rowspan="100"></td>
    <td width="357" valign="top" bgcolor="#ffffff" rowspan="100"><font size="3"> <table
    width="357" border="0" cellpadding="0" cellspacing="0">
      <font face="verdana, arial, geneva, sans-serif" size="2">
      <tr>
        <td></font><font face="宋体"><nobr>WM_scaleFont()</nobr></font>根据浏览器窗口的尺寸相应缩放文字<br>
        尺寸。如果你所设计的网页不希望通过滚动条的上下<br>
        移动,而是将其按照窗口的尺寸显示的话,这个函数<br>
        对你绝对有用。为了是该函数正常工作,在设置<font face="宋体">CSS</font><br>
        单位和图象及<font face="宋体">DIV</font>的尺寸时最好使用相对单位(<font
        face="宋体">em, <br>
        ex, %</font>)。 <p><b>用法:</b><font face="宋体"><tt>WM_scaleFont(targetSize, 
        initialFontSize, <br>
        fontUnits);</tt> </font></p>
        <p><font face="宋体"><tt>targetSize</tt></font>是浏览器窗口的尺寸,你所设计的网页的<br>
        显示尺寸将依据浏览器窗口的尺寸设置。<br>
        <font face="宋体"><tt>initialFontSize</tt></font>是当浏览器窗口尺寸为<font
        face="宋体"><tt>targetSize</tt></font><br>
        时你希望让文字显示的缺省尺寸。<font face="宋体"><tt>fontUnits</tt></font>是网页<br>
        初始<font face="宋体">body</font>标签的尺寸单位(<font face="宋体">pt</font>或<font
        face="宋体">pxl</font>)。 </p>
        <p><font face="宋体">Internet Explorer</font>要求在确定<font face="宋体">body</font>标签的尺寸之前<br>
        就载入浏览器窗口。而<font face="宋体">Netscape</font>要求在网页首部调用<br>
        该函数,以便执行<font face="宋体">style</font>标签。所以你需要插入两个<br>
        调用:一个放在首部的<font face="宋体"><tt>script</tt></font>标签中,另一个放在<br>
        <font face="宋体">body</font>标签后的<font face="宋体">script</font>标签中。 </p>
        <pre><font face="宋体">&lt;head&gt;
&lt;script&gt;
if (document.layers)
  WM_scaleFont(targetSize, initialFontSize, fontUnits);
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script&gt;
if(document.all){
WM_scaleFont(targetSize, initialFontSize, fontUnits);
}
&lt;/script&gt;
</font></pre>
        <p>你希望进行比例缩放的所有文字必须采用一个相对<br>
        <font face="宋体">CSS</font>单位<font face="宋体">(em, ex, %)</font>。其尺寸相应于<font
        face="宋体">body</font>文字的缺<br>
        省缺省尺寸。例如,如果你将设定缺省文字尺寸为<br>
        <font face="宋体">40px</font>并将某些文字的尺寸设定为<font face="宋体">50</font>%。则当浏览器<br>
        窗口以<font face="宋体">targetsize</font>尺寸打开时,则这些文字的尺寸<br>
        为<font face="宋体">20px</font>,如果浏览器窗口以<font face="宋体">targetSize</font>一半的尺寸<br>
        打开时,则这些文字的尺寸为<font face="宋体">10px</font>。 </p>
        <p><b>要求同时使用:</b><font face="宋体"><a href="wm_ns_css_rs_fx.html" tppabs="http://www.webmonkey.com.cn/javascript/code/wm_ns_css_rs_fx.html">WM_netscapeCSSResizeFix()</a> 
        </font></td>
      </tr>
    </table>
    <p><b>欢迎剪贴使用<font face="宋体">!</b> </font></p>
    <form>
      <p><font face="宋体"><textarea cols="45" rows="20" wrap="off">

&lt;script language=&quot;JavaScript&quot;&gt;
<!--



function WM_scaleFont(targetSize, initialFontSize, fontUnit) {

/*
WM_scaleFont()
Author: Taylor
Author Email: taylor@wired.com
Author URL: http://www.taylor.org/
Package URL: http://www.hotwired.com/webmonkey/

WM_scaleFont() scales the fonts on the page depending on 
the width of the window. It's very useful for creating a 
page that's designed to fit within a window without scrolling. 
For the whole effect to work well, use relative units 
(em, ex, %) for all your CSS positioning and for 
image and DIV sizes.

Usage: Internet Explorer requires the body tag to be loaded 
before you can determine the width, and Netscape needs to call 
the function in the head to write out the style tag. So you 
need to insert two calls: one in a script tag in the head, 
after any style sheets, and the other in a script tag right 
after the body. 
*/

  // This checks for the existence of the document objects and 
  // properties where we store the passed variables.
  if (typeof document.WM == 'undefined'){
    document.WM = new Object;
  }
  if (typeof document.WM.WM_scaleFont == 'undefined') {
    document.WM.WM_scaleFont = new Object;
    document.WM.WM_scaleFont.screenTarget = targetSize;
    document.WM.WM_scaleFont.targetBodyFontSize = initialFontSize;
    document.WM.WM_scaleFont.fontUnit = fontUnit;
  }
  // The actual screen width is gotten here.
  if (document.all) {
    var screenWidth = document.body.offsetWidth;
  } else if (document.layers) {
    var screenWidth = window.innerWidth;
  }
  // This one line is the core of the routine. It takes the 
  // targeted font size and divides it by the actual width 
  // times the targeted width.
  var scaledFont = parseInt(document.WM.WM_scaleFont.targetBodyFontSize) * (screenWidth / document.WM.WM_scaleFont.screenTarget);
  // Now this new font size is applied to the body. 
  // For IE, it changes the body's style declaration and 
  // sets things up such that on resize this function is 
  //called again. For Netscape, it writes out a style tag 
  // in the head, and then depends on WM_netscapeCssFix() 
  // to reload the page if it's been resized. 
  if (document.all) {
    document.body.style.fontSize = scaledFont + document.WM.WM_scaleFont.fontUnit;
    window.onresize = WM_scaleFont;
  } else if(document.layers) {
    var netscapeScaleReturn = '';
    document.writeln(netscapeScaleReturn);
  }
}


// -->

&lt;/script&gt;

</textarea> </font></font></p>
    </form>
    </td>
  </tr>
  <tr>
    <td width="155" valign="bottom" bgcolor="#FFFFB5"><font face="宋体"><br>
    </font><font size="2" face="宋体">问题? 建议? 请<a href="mailto:bruce@itc.cn.net">告诉</a>网猴。</font></td>
  </tr>
</table>

<p><font face="宋体"><br>
</font></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -