• ie6/7/8 FireFox Google 浏览器问题参考


    http://www.cnblogs.com/cloudgamer/archive/2009/12/22/ImagePreview.html

    http://www.cnblogs.com/shengtianlong/archive/2010/11/29/1891010.html

    http://zhidao.baidu.com/question/223390215.html

    http://www.iefans.net/ie-shangchuan-bendi-lujing-fakepath/

    http://www.yunsec.net/a/Special/wzjs/wzbc/aspx/2010/1201/7240_2.html

    //火狐浏览器读取url

    function readFileFirefox(fileBrowser) {

        try {

            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

        }

        catch (e) {

    alert("需要设置一下浏览器才能使用,在URL地址栏中输入about:config打开,进入浏览器参数配置,找到"signed.applets.codebase_principal_support",将它的值切换为true;如果找不到"signed.applets.codebase_principal_support",则右键 新建 > 布尔 > 输入变量'signed.applets.codebase_principal_support' , 刷新浏览器重试!");

            //alert('Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again.');

            return;

        }

        var fileName=fileBrowser.value;

        var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);

        try {

            // Back slashes for windows

            file.initWithPath( fileName.replace(/\//g, "\\\\") );

        }

        catch(e) {

            if (e.result!=Components.results.NS_ERROR_FILE_UNRECOGNIZED_PATH) throw e;

            alert("File '" + fileName + "' cannot be loaded: relative paths are not allowed. Please provide an absolute path to this file.");

            return;

        }

        if ( file.exists() == false ) {

            alert("File '" + fileName + "' not found.");

            return;

        }

        return file.path;

        //alert(file.path); // I test to get the local file's path.

       /* var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream );

        try {

        is.init( file,0x01, 00004, null);

        }

        catch (e) {

            if (e.result!=Components.results.NS_ERROR_FILE_ACCESS_DENIED) throw e;

            alert("Unable to access local file '" + fileName + "' because of file permissions. Make sure the file and/or parent directories are readable.");

            return;

        }

        var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream );

        sis.init( is );

        var data = sis.read( sis.available());

        */

        //alert("Data from file: " + data); // I test to get the local file's data.

    }

    //更改文件URL

    function updatePath(){

    var $file = $('#exprot_youfei_list1');

    var $file2 = $('#exprot_youfei_list2');

    $file2.val($file.val());

    //alert(navigator.userAgent);

    //var file = document.getElementById('exprot_youfei_list1');

    //var file2 = document.getElementById('exprot_youfei_list2');

    //var show = document.getElementById('showurl');

    ////IE 直接给值

    //if (navigator.userAgent.indexOf("MSIE")!=-1) {

    //

    //var bb = navigator.userAgent.substr(navigator.userAgent.indexOf("MSIE"),8);

    //alert(bb);

    //

    //file2.value = file.value;

    //show.innerHTML = file.value;

    //if(bb == "MSIE 8.0" || bb == "MSIE 9.0"){

    ////>IE7

    ////alert(">7");

    //file.select();

    //try{

    //    var va = document.selection.createRange().text;

    //    alert("va="+va);

    //    show.innerHTML = va;

    //    file2.value = va;

    //}catch(e){

    //alert("error"+e);

    //}finally{

    //document.selection.empty();

    //}

    //}

    //

    // } else if (navigator.userAgent.indexOf("Firefox")!=-1){

    //

    //       file2.value =  readFileFirefox(file);

    //       show.innerHTML = file2.value;

    // } else if( navigator.userAgent.indexOf("Chrome")!=-1){

    //alert("不兼容此浏览器,URL错误");

    // try{

    // var s = file.value;//files.getAsDataURL();

    // file2.value =  s;

    // show.innerHTML = s;

    // }catch(e){

    // alert("异常"+e);

    // }

    // }else{

    //

    // }

    }

  • 相关阅读:
    Valgrind使用转载 Sanny.Liu
    Caffe模型读取 Sanny.Liu
    JNI动态库生成、编译、查看相关简易资料 Sanny.Liu
    GDB调试,转载一位大牛的东西 Sanny.Liu
    Android处理图片工具(转载) Sanny.Liu
    添加可点击的imagebottom,有个点击动画效果 Sanny.Liu
    去OpenCVManager,大部分为转载,仅当自己学习使用 Sanny.Liu
    转载: vim使用技巧 Sanny.Liu
    结构体数组初始化三种方法,转载 Sanny.Liu
    AsyncTask机制学习 Sanny.Liu
  • 原文地址:https://www.cnblogs.com/yifenghong/p/2459086.html
Copyright © 2020-2023  润新知