zoukankan      html  css  js  c++  java
  • javascript 路径读取

    //获取当前文件全路径

    <script language="javascript">

    alert(window.location.href);

    alert(window.location);

    alert(location.href);

    alert(parent.location.href);

    alert(top.location.href);

    alert(document.location.href);

    alert(document.URL);

    </script>

    //获取当前目录方法

    <script type="text/javascript">

    //方法一

    var str = location.href;

    var arr = str.split("/");

    delete arr[arr.length-1];

    var dir = arr.join("/");

    alert(dir);

    //方法二

    alert(location.href.substring(0,location.href.lastIndexOf('/')));

    </script>

    //获取当前文件名

    <script   language=javascript>  

    var  filename=location.href;

    filename=filename.substr(filename.lastIndexOf('/')+1);  

    alert(filename);  

    </script>

    chrome 获取 input文件的路径

    1. 加密的的blob  

    <input type="file" id="files" name="files[]"  multiple  />
    <output id="list"></output>
    <input type="button" onclick="onchange1()" value="button" />
    
    <script>
    function onchange1(){
        //alert(document.getElementById('files').value);
        var f = window.URL.createObjectURL(document.getElementById('files').files[0]);
        alert(f);
    }
    </script>

    获取项目路径

    <!DOCTYPE html>
    <html lang='en'>
        <head>
        <title>read</title>
        <meta charset='utf-8' >
        </head>
        <body>
            <form action="#" onsubmit="return savefile(this);">
            <!-- 文本类型为txt 切换回文本框快捷键为Alt+z -->
            <textarea name="txt" title=" Text edit area - Alt+Z " accesskey="z" rows="10" cols="80">123</textarea>
            <div>
            <!-- 保存文本快捷键为Alt+s -->
            <!-- 把鼠标移动到元素上面,就会显示title的内容 -->
                <input title=" Save - Alt+S " class="key" accesskey="s" type="submit" value=" Save ">
                
                <label title=" Filename - Alt+A " for="filename">As</label>
                <input name="filename" class="it" id="filename" accesskey="a" type="text" size="40" value="D:MazeSet1">
                <select name="ext" title=" Extension ">
                    <option value="iso-8859-1">.html</option>
                    <!-- selected 表示没人选择项 -->
                    <option selected="selected" value="utf-8">.txt</option>
                </select>
                <input title=" Remove null bytes - Alt+U " class="key" accesskey="u" onclick="this.form.elements.txt.value = unnull( this.form.elements.txt.value );" type="button" value=" Unnull ">
                <input title=" Reset the form to its initial state - Alt+R " class="key" accesskey="r" type="reset" value=" Reset ">
            </div>
        <input type="file" id="files" name="files[]"  multiple  />
    <output id="list"></output>
    <input type="button" onclick="onchange1()" value="button" />
    <script>
    function getContextPath(){   
                    var pathName = document.location.pathname;   
                    var index = pathName.substr(1).indexOf("/");   
                    var result = pathName.substr(0,index+1);   
                    alert(pathName);
                    return result;   
                } 
                getContextPath();
      
    </script>
        </body>
    </html>

  • 相关阅读:
    ArcGIS Engine 中的多线程使用
    Arcgis栅格时序地图制作---时间轴动态展示多期影像
    R树空间索引
    R-Tree空间索引算法的研究历程和最新进展分析
    学生表、课程表、 成绩表 、教师表sql练习
    Mysql建表出现1005错误
    MySQL数据类型详解
    数据库操作语句类型(DQL、DML、DDL、DCL)简介
    Spring MVC标签<mvc: annotation-driven />小结 原
    EasyUI Menu 菜单
  • 原文地址:https://www.cnblogs.com/jiangfeilong/p/10733617.html
Copyright © 2011-2022 走看看