三剑客【HTML + js + css】

突然在群里找到一个HTML的文件,在这里记录一下相关内容。。。

Html网页的代码

  1. 贴图:

    <img src="path" />
    
  2. 链接:

    <a href="path">写上你想写的字</a>
    
  3. 在新窗口打开连接:

    <a href="path" target="_blank">写上要写的字</a>
    

    消除链接的下划线在口打开连接:

    <a href="path" style="text-decoration:none">写上你想写的字</a>
    
  4. 移动字体(走马灯):

    默认是从右飘到左边

    <marquee>写上你想写的字</marquee>
    
  5. 字体加粗:

    <b>写上你想写的字</b>
    
  6. 字体斜体:

    <i>写上你想写的字</i>
    
  7. 字体下划线:

     <u>写上你想写的字</u>
    
  8. 字体删除线:

    <s>写上你想写的字</s>
    
  9. 字体加大:

    <big>写上你想写的字</big>
    
  10. 字体控制大小: (其中字体大小可从h1-h5,h1最大,h5最小,常用它写标题)

    <h1>写上你想写的字</h1> 
    
  11. 更改字体颜色:(其中value值在000000与ffffff(16位进制)之间

    <font color="#value">写上你想写的字</font>
    
  12. 贴音乐:

    <embed src="path" width=300 height=45 type=audio/mpeg autostart="false">
    

    1

  13. 贴flash:

    <embed src="flash地址" width="宽度" height="高度">
    
  14. 贴影视文件

    <img dynsrc="文件地址" width="宽度" height="高度" start=mouseover>
    
  15. 换行:

    <br/>
    
  16. 段落:

    <br/>
    
  17. 固定文章的格式:(显示的段落会同在编译器中写的格式一样)

    <pre>正文</pre>
    
  18. 页面背景:

    <body background="背景图片地址">
    
  19. 固定页面背景不随滚动条滚动:

    <body style="background-image: url('image/1.jpg');background-size: 100%;background-repeat: no-repeat;background-attachment: fixed">
    <!--代码中的style依次表示: 背景图片地址;图片大小;背景图片不重复;指定不滚动-->
    
  20. 定制页面背景颜色:

    <body bgcolor="#value">(value值见 11.)
    
  21. 页面背景音乐:

    <audio style="display: none" autoplay="autoplay" controls="controls"loop="loop"  preload="auto" src="音乐路径">你的浏览器版本太低,不支持audio标签</audio>
    <!--第一句display表示是否显示播放器器件;autoplay设置自动播放;controls显示按钮;loop重复播放(loop一直循环播放);preload加载预备播放-->
    
  22. 在自己的页面显示其他页面的信息:

    <iframe src="相关地址" width="宽度" height="高度"></iframe>
    
  23. 禁用右键

    <body oncontextmenu="return false"> 
    

    或者(方正我试了不行,但是有的可以)

    <body style="overflow-y: hidden"> 
    
  24. windows.open

    <a href="#" onclick="javascript :window.open(文件路径/文件名,newwindow,toolbar=no,scrollbars=yes,resizable=no,top=0,left=0, width=400,height=300);">文字或图片</a> 
    

    参数解释:
    < SCRIPT LANGUAGE=“javascript”> js脚本开始;
    window.open 弹出新窗口的命令;
    文件路径/文件名 弹出窗口的文件名;
    newwindow 弹出窗口的名字(不是文件名),非必须,可用空代替;
    width=400 窗口宽度;
    height=300 窗口高度;
    top=0 窗口距离屏幕上方的象素值;
    left=0 窗口距离屏幕左侧的象素值;
    toolbar=no 是否显示工具栏,yes为显示;
    menubar,scrollbars 表示菜单栏和滚动栏。
    resizable=no 是否允许改变窗口大小,yes为允许;
    location=no 是否显示地址栏,yes为允许;
    status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
    < /SCRIPT> js脚本结束

  25. 简单的页面加密:

    <script LANGUAGE="javascript">
    function loopy(){
        var sWord ="";
        var pass = "login";
        while(sWord != pass){sWord=prompt("请输入你的登陆密码");}
        alert("登陆成功!");
    }
    loopy();
    </script>
    
  26. 让浏览器在保存页面时保存失败(这个我也用不了,也不知道为什么)

    <NOSCRIPT><iframe src="*.html"></iframe></NOSCRIPT>
    
  27. 页面自动刷新

    <META HTTP-EQUIV="Refresh" content="20">
    
  28. 页面自动跳转:

     <META HTTP-EQUIV="Refresh" CONTENT="2;URL='*.html'">
    
  29. 保持layer在最前面,而不被Iframe、Object所覆盖 在Layer中再插Iframe 或 Object 设z-Index值

    <div style="z-Index: 2"><object xxx></object> # 前面
          <div style="z-Index:1"><object xxx></object> # 后面
              <div id="Layer2" style="position:absolute; top: 40px;width:400px;height:95px;z-index:2"> height=100% width=100%>
                  <iframe width=0 height=0></iframe>
                  </div>
              <div id="Layer1" style="position:absolute; top:50px;width:200px; height:115px;z-index:1">
                  <iframe height=100% width=100%></iframe>
                 
    
            </div>
        </div>
    </div>
    
  30. 返回上一页:

    <a href=javascript :history.back(1)>
    
  31. 关闭窗口:

    <a href=javascript :self.close()>
    
  32. 关于iframe的透明背景

    <IFRAME ID="iFrame1" SRC="path" allowTransparency="true" style="background-color: green"></IFRAME>
    
  33. 彻底屏蔽 table 中使用右键

    <table border oncontextmenu=return(false)><td>no</table>
    
  34. 全文 防止复制、取消选取

    <body onselectstart="return false">
    

    防止粘贴

    <body onpaste="return false">
    

    防止复制

    <body oncopy="return false;" oncut="return false;">
    
  35. IE地址栏前换成自己的图标

    <link rel="Shortcut Icon" href="favicon.ico">
    

    可以在收藏夹中显示出你的图标

    <link rel="Bookmark" href="favicon.ico">
    
  36. 关闭输入法:

    <input style="ime-mode:disabled">
    
  37. 永远都会带着框架

    <script language="JavaScript">
    if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
    </script>
    
  38. 防止被人frame (如果被frame直接显示自己的页面)

    <SCRIPT LANGUAGE=JAVASCRIPT>
        if (top.location != self.location) top.location=self.location;
    </SCRIPT>
    
  39. 删除时确认

    <a href="javascript :if(confirm('确实要删除吗?'))location="boos.asp? &areyou=删除&page=1"">删除</a>
    
  40. 屏蔽功能键Shift,Alt,Ctrl

    <script>
        function look(){
            if(event.shiftKey)
                alert("禁止按Shift键!"); //可以换成ALT CTRL 
        }
        document.onkeydown=look;
    </script>
    
  41. 没有滚动条:
    让竖条没有:

    <body style="overflow:scroll;overflow-y:hidden"> </body>
    

    让横条没有:

    <body style="overflow:scroll;overflow-x:hidden"> </body> 
    

    两个都去掉?更简单了

    <body scroll="no"> </body>
    
  42. 怎样去掉图片链接点击后,图片周围的虚线?

    <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
    
  43. 电子邮件处理提交表单

    <form name="form1" method="post" action="mailt****@***.com" enctype="text/plain">
        <input type=submit>
    </form>
    
  44. 在打开的子窗口刷新父窗口的代码里如何写?

    window.opener.location.reload()
    
  45. 如何设定打开页面的大小

    <body onload="top.resizeTo(300,200);"> 
    

    打开页面的位置

    <body onload="top.moveBy(300,200);">
    
  46. 在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动

        <STYLE>
        body {
            background-image: url("image/1.jpg");
            background-repeat:no-repeat;
            background-position:center;
            background-attachment: fixed
        }
    </STYLE>
    
  47. 检查一段字符串是否全由数字组成

    <script language="Javascript">
    function checkNum(str){return str.match(//D/)==null} 
        alert(checkNum("1232142141"))
        alert(checkNum("123214214a1"))
    </script>
    
  48. 获得一个窗口的大小

    document.body.clientWidth; document.body.clientHeight
    
  49. 怎么判断是否是字符

    if (/[^/x00-/xff]/g.test(s)) alert("含有汉字"); 
    else alert("全是字符");
    
  50. TEXTAREA自适应文字行数的多少

    <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> 
    </textarea>
    
  51. 日期减去天数等于第二个日期

    <script language=Javascript>
        function cc(dd,dadd)
        {
    //可以加上错误处理 
            var a = new Date(dd)
            a = a.valueOf()
            a = a - dadd * 24 * 60 * 60 * 1000
            a = new Date(a)
            alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
        } cc("12/23/2002",2)
    </script>
    
  52. 选择了哪一个Radio

    <HTML><script language="vbscript"> 
    function checkme() 
    for each ob in radio1 
    if ob.checked then window.alert ob.value 
    next 
    end function 
    </script><BODY>
    <INPUT name="radio1" type="radio" value="style" checked>Style
    <INPUT name="radio1" type="radio" value="barcode">Barcode
    <INPUT type="button" value="check" onclick="checkme()">
    </BODY></HTML>
    
  53. ENTER键可以让光标移到下一个输入框

    <input onkeydown="if(event.keyCode==13)event.keyCode=9">
    
  54. 禁止鼠标右键,把Demo的图片全都设为表格的背景,表格的大小与图片的大小一样。这样做看起来是一样的,主要是防止鼠标经过图片时会出现另存的按钮。禁止鼠标右键的代码很简单:

    <script LANGUAGE="JavaScript">
        function click() { if (event.button==2) {
                alert("呵呵,不好意思,你甭想使用右键下载图片:"); 
            } 
        } document.onmousedown=click;
    </script>
    
  55. 在网页的Head部分加入如下代码,这段代码的主要功能是屏蔽PrintScreen键,不断清空剪贴版,防止图片被用文件——另存为菜单另存。

    <script language="javascript">
        function testclip(){
            try {
                if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL"))
                {
                    null;
                }
            }
            catch(e){
                clipboardData.setData("Text","")
            }
            setTimeout("testclip()",500)
        }
        testclip();
    </script>
    
  56. 各种样式的光标:

    auto :标准光标
    default :标准箭头
    hand :手形光标
    wait :等待光标
    text :I形光标
    vertical-text :水平I形光标
    no-drop :不可拖动光标
    not-allowed :无效光标
    help :?帮助光标
    all-scroll :三角方向标
    move :移动标
    crosshair :十字标
    e-resize
    n-resize
    nw-resize
    w-resize
    s-resize
    se-resize
    sw-resize
    
  57. 页面进入和退出的特效

    进入页面:<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
    
    推出页面:<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
    

    用哪种特效,取值为1-23:
      0 矩形缩小
      1 矩形扩大
      2 圆形缩小
      3 圆形扩大
      4 下到上刷新
      5 上到下刷新
      6 左到右刷新
      7 右到左刷新
      8 竖百叶窗
      9 横百叶窗
      10 错位横百叶窗
      11 错位竖百叶窗
      12 点扩散
      13 左右到中间刷新
      14 中间到左右刷新
      15 中间到上下
      16 上下到中间
      17 右下到左上
      18 右上到左下
      19 左上到右下
      20 左下到右上
      21 横条
      22 竖条
      23 以上22种随机选择一种

  58. 鼠标光标:

    <BODY style="CURSOR: url(http://203.73.125.205/~liangmi2/farmfrog01.cur`)">
    
  59. 怎样实现在任务栏显示小图标的效果? (要使用绝对地址)
    有些站点,访问时会在地址栏地址前显出小图标,添加到收藏夹后也在收藏栏中显示图标,
    这样很好的与其它站点有了区别。
    要达到这个效果,先需做出这个图标文件,图像为16*16像素,不要超过16色。文件格式为ico,然后上传至你的网站。
    然后,在需要的页面中,加上以下html语句到文件的和之间(假设以上ico文件的地址http://happyisland.126.com/icon.ico)。
    <link REL="SHORTCUT ICON"href=“http:///happyisland.126.com/icon.ico”;>
    如果访问者的浏览器是IE5.0,就不需加任何代码,只要将图标文件上传到网站的根目录下即可。
    1,META标签里的代码是什么意思?
    是放于与之间的标记.以下是我总结它在网页中最常见的几种。

    该网页的关键字,作用于搜索引擎的登录,事实上它在现在的网站中并没什么用。


    设定这是 HTML 文件及其编码语系,简体中文网页使用charset=gb2312,繁体中文使用charset=big5,或者不设编码也可,纯英文网页建议使用 iso-8859-1。

    这只表示该网页由什么编辑器写的。

    这行较为实用,能于预定秒数内自动转到指定网址。原代码中 10 表示 10秒。
    2,怎么改变滚动条的颜色,只有ie5.5版本以上才能支持。
    这是使用CSS语言,在次说明一下,它和我的浏览器版本有一定的关系。
    scrollbar-arrow-color:上下按钮上三角箭头的颜色。
    scrollbar-base-color:滚动条的基本颜色。
    scrollbar-dark-shadow-color:立体滚动条强阴影的颜色
    scrollbar-face-color:立体滚动条凸出部分的颜色
    scrollbar-highlight-color:滚动条空白部分的颜色
    scrollbar-shadow-color立体滚动条阴影的颜色。
    scrollbar-track-color:#99CC33;
    scrollbar-3dlight-color:#A8CBF1;

    <style> 
    <!-- 
    BODY {
    scrollbar-face-color:#99CC33;//(立体滚动条凸出部分的颜色) 
    scrollbar-highlight-color:#A8CBF1;//(滚动条空白部分的颜色) 
    scrollbar-shadow-color:#A8CBF1;//(立体滚动条阴影的颜色) 
    scrollbar-arrow-color:#FF9966;//(上下按钮上三角箭头的颜色) 
    scrollbar-base-color:#A8CBF1; //(滚动条的基本颜色) 
    scrollbar-darkshadow-color:#A8CBF1; //(立体滚动条强阴影的颜色)
    scrollbar-track-color:#99CC33;
    scrollbar-3dlight-color:#A8CBF1; 
    } 
    --> 
    </style>
    
  60. 如何给图片抖动怎做的.

    <SCRIPT language=javascript1.2>
        <!--
        var rector=2
        var stopit=0
        var a=1
        var count=0
        function init(which){
            stopit=0
            shake=which
            shake.style.left=0
            shake.style.top=0
        }
        function rattleimage(){
            if ((!document.all&&!document.getElementById)||stopit==1||count==100)
                return
            count++
            if (a==1){
                shake.style.top=parseInt(shake.style.top)+rector
            }
            else if (a==2){
                shake.style.left=parseInt(shake.style.left)+rector
            }
            else if (a==3){
                shake.style.top=parseInt(shake.style.top)-rector
            }
            else{
                shake.style.left=parseInt(shake.style.left)-rector
            }
            if (a<4)
                a++
            else
                a=1
            setTimeout("rattleimage()",50)
        }
        function stoprattle(which){
            stopit=1
            count=0
            which.style.left=0
            which.style.top=0
        }
        //-->
    </SCRIPT>
    <style>.shakeimage {POSITION: relative}
    </style>
    <img src="图片的路径" onmouseout=stoprattle(this) onmouseover=init(this);rattleimage() class=shakeimage>
    
  61. 如何在网页中实现flash的全屏播放?
    只要在调用swf文件的HTML中将WIDTH和HEIGHT的参数设为100%即可,当然也可以在Flash导出HTML文件的设置中进行设置,方法是:打开File菜单;选Publish Settings弹出导出设置对话框;在HTML标签下的Dimensions选项,下拉后选中Percent(百分比),并在WIDTH 和HEIGHT框中填100.就行了。

  62. 在Flash中,如果屏蔽鼠标右键?FS命令都是什么意思?

    fscommand ("fullscreen", "true/false";(全屏设置,TRUE开,FALSE关) 
    fscommand ("showmenu", "true/false";(右键菜单设置,TRUE显示,FALSE不显示) 
    fscommand ("allowscale", "true/false";(缩放设置,TRUE自由缩放,FALSE调整画面不影响影片本身的尺寸) 
    fscommand ("trapallkeys", "true/false";(快捷键设置,TRUE快捷键开,FALSE快捷键关) 
    fscommand ("exec";(EXE程序调用) 
    fscommand ("quit";(退出关闭窗口)
    
  63. 双击鼠标左键来滚动背景,单击停止。

    <SCRIPT language=javascript>
        var currentpos,timer;
        function initialize()
        {
            timer=setInterval("scrollwindow()",16);
        }
        function sc(){
            clearInterval(timer);
        }
        function scrollwindow()
        {
            currentpos=document.body.scrollTop;
            window.scroll(0,++currentpos);
            if (currentpos != document.body.scrollTop)
                sc();
        }
        document.onmousedown=sc
        document.ondblclick=initialize
    </SCRIPT>
    
  64. 用javascript代码来实现闪烁按钮。

    <form method="POST" action="--WEBBOT-SELF--">
        <input type="button" name=SUB value="闪烁" id=flashit style="BORDER: 1px solid ;BACKGROUND-COLOR: #FFFFFF">
    </form>
    <script>
        if (document.all&&document.all.flashit)
        {
            var flashelement=document.all.flashit
            if (flashelement.length==null)
                flashelement[0]=document.all.flashit
            function changecolor(which)
            {
                if (flashelement[which].style.color==`#800000`)
                    flashelement[which].style.color="#0063A4"
                else
                    flashelement[which].style.color="#800000"
            }
            if (flashelement.length==null)
                setInterval("changecolor(0)",1000)
            else
                for (i=0;i<flashelement.length;i++)
                {
                    var tempvariable=`setInterval("changecolor(`+i+`)",`+`1000)`
                    eval(tempvariable)
                }
        }
    </script>
    
  65. 画竖线

    <table border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td bgcolor="#FF0000" height="200" width="1"></td>
        </tr>
    </table>
    
    <hr color="red" width="1" size="100%">
    
  66. 拖动容器:
    慢慢试着改吧:┭┮﹏┭┮

    <html>
    <head>
        <title>拖动改变层的大小</title>
        <meta charset="UTF-8">
        <style> {
            box-sizing: border-box; moz-box-sizing: border-box
        }
        #testDiv     { background-color: buttonface; background-repeat: repeat; background-attachment: scroll; color: #3969A5; height: 300px;left: 30px; overflow: hidden; width: 500px; z-index: 2;border: 2px outset white; margin: 0px; padding: 2px;background-position: 0% 50% }
        body         { font-family: Verdana; font-size: 9pt }
        #innerNice   { background-color: white; background-repeat: repeat; background-attachment: scroll; color: #3969A5; height: 100%; overflow: auto; width: 100%; border: 2px inset white; padding: 8px;background-position: 0% 50% }
        p{
            border: 1px solid black;
        }
        </style>
        <SCRIPT language=javascript>
            var theobject = null;
            function resizeObject() {
                this.el        = null; //pointer to the object
                this.dir    = "";      //type of current resize (n, s, e, w, ne, nw, se, sw)
                this.grabx = null;   //Some useful values
                this.graby = null;
                this.width = null;
                this.height = null;
                this.left = null;
                this.top = null;
            }
            function getDirection(el) {
                var xPos, yPos, offset, dir;
                dir = "";
                xPos = window.event.offsetX;
                yPos = window.event.offsetY;
                offset = 8; //The distance from the edge in pixels
                if (yPos<offset) dir += "n";
                else if (yPos > el.offsetHeight-offset) dir += "s";
                if (xPos<offset) dir += "w";
                else if (xPos > el.offsetWidth-offset) dir += "e";
                return dir;
            }
    
    
            function doDown() {
                var el = getReal(event.srcElement, "className", "resizeMe");
    
    
                if (el == null) {
                    theobject = null;
                    return;
                }
                dir = getDirection(el);
                if (dir == "") return;
                theobject = new resizeObject();
                theobject.el = el;
                theobject.dir = dir;
                theobject.grabx = window.event.clientX;
                theobject.graby = window.event.clientY;
                theobject.width = el.offsetWidth;
                theobject.height = el.offsetHeight;
                theobject.left = el.offsetLeft;
                theobject.top = el.offsetTop;
                window.event.returnValue = false;
                window.event.cancelBubble = true;
            }
    
    
            function doUp() {
                if (theobject != null) {
                    theobject = null;
                }
            }
    
    
            function doMove() {
                var el, xPos, yPos, str, xMin, yMin;
                xMin = 8; //The smallest width possible
                yMin = 8; //             height
                el = getReal(event.srcElement, "className", "resizeMe");
                if (el.className == "resizeMe") {
                    str = getDirection(el);
    //Fix the cursor 
                    if (str == "") str = "default";
                    else str += "-resize";
                    el.style.cursor = str;
                }
    //Dragging starts here
                if(theobject != null) {
                    if (dir.indexOf("e") != -1)
                        theobject.el.style.width = Math.max(xMin, theobject.width + window.event.clientX - theobject.grabx) + "px";
    
                    if (dir.indexOf("s") != -1)
                        theobject.el.style.height = Math.max(yMin, theobject.height + window.event.clientY - theobject.graby) + "px";
    
    
                    if (dir.indexOf("w") != -1) {
                        theobject.el.style.left = Math.min(theobject.left + window.event.clientX - theobject.grabx, theobject.left + theobject.width - xMin) + "px";
                        theobject.el.style.width = Math.max(xMin, theobject.width - window.event.clientX + theobject.grabx) + "px";
                    }
                    if (dir.indexOf("n") != -1) {
                        theobject.el.style.top = Math.min(theobject.top + window.event.clientY - theobject.graby, theobject.top + theobject.height - yMin) + "px";
                        theobject.el.style.height = Math.max(yMin, theobject.height - window.event.clientY + theobject.graby) + "px";
                    }
    
                    window.event.returnValue = false;
                    window.event.cancelBubble = true;
                }
            }
    
    
            function getReal(el, type, value) {
                temp = el;
                while ((temp != null) && (temp.tagName != "BODY")) {
                    if (eval("temp." + type) == value) {
                        el = temp;
                        return el;
                    }
                    temp = temp.parentElement;
                }
                return el;
            }
    
    
            document.onmousedown = doDown;
            document.onmouseup   = doUp;
            document.onmousemove = doMove;
    
        </SCRIPT>
    </head>
    <body>
    <div class="resizeMe" id="testDiv" >
          <div id="innerNice">
            <p align="center" style="border: 1px solid black;"> </p>
            <p align="center" style="border: 1px solid black;">
        请在边框处拖动鼠标</p>
            <p> </p>
            <p> </p>
            <p> </p>
          </div>
    </div>
    <div style="border: 1px solid black"><A href="http://www.999jiujiu.com/">http://www.999jiujiu.com/</A></div>
    </body>
    </html>
    
  67. frameset

    <frameset cols="25%,75%">
    
      <frame src="/example/html/frame_a.html">
      <frame src="/example/html/frame_b.html">
    
    </frameset>
    
  68. summary

    <details>
      <summary>HTML 5</summary>
      <ul>
    	<li>232</li>
    	<li>23232</li>
    	<li>23232323</li>
      </ul>
    </details>
    

    在这里插入图片描述

其他“:https://www.cnblogs.com/services/archive/2009/10/16/1584574.html

猜你喜欢

转载自blog.csdn.net/qq_44009311/article/details/102510427
今日推荐