Pogledajte određenu poruku
Staro 20. 08. 2010.   #1
35-68
Душан Бошкић
Qualified
 
Avatar 35-68
 
Datum učlanjenja: 11.09.2005
Lokacija: 11277 Ugrinovci
Poruke: 109
Hvala: 67
384 "Hvala" u 17 poruka
35-68 is on a distinguished road35-68 is on a distinguished road35-68 is on a distinguished road35-68 is on a distinguished road
Pošaljite poruku preko MSN za 35-68 Pošaljite poruku preko Skype™ za 35-68
Lightbulb [Firefox Windows] Pokretanje aplikacija i dokumenata sa lokalne mreže

HTML kôd:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
        <title>Launch local area network files from server</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta http-equiv="Content-Script-Type" content="text/javascript" />
        <meta http-equiv="Content-Language" content="en-US" />
        <meta http-equiv="author" content="xhtml.rs" />
        <script type="text/javascript">
            var XPConnect = false;
            if (navigator.userAgent.indexOf('Firefox') !== -1) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
                    XPConnect = true;
                } catch(e) {
                    alert(e + '\r\nGo to about:config and set signed.applets.codebase_principal_support value to true.');
                    /*
                        about:config => signed.applets.codebase_principal_support => Toggle to true
                    */
                }
            }

            if (XPConnect) {
                var localFile = {
                    _loaded: false,
                    init: function(event) {
                        if (!localFile._loaded) {
                            var href = document.getElementsByTagName('a');
                            for (var i = 0; i < href.length; i++) {
                               href[i].addEventListener('click', localFile._click, false);
                            }
                            localFile._loaded = true;
                        }
                    },
                    _click: function(event) {
                        var a = event.target;
                        var href = a.getAttribute('href');
                        if (href.indexOf('file://') !== -1) {
                            localFile._launch(event, href);
                            return false;
                        } else {
                            return true;
                        }
                    },
                    _launch: function(event, path) {
                        try {
                            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
                            var Cc = Components.classes;
                            var Ci = Components.interfaces;
                            var nsIProcess = Ci.nsIProcess;
                            var nsILocalFile = Ci.nsILocalFile;
                            var nsIIOService = Ci.nsIIOService;
                            var nsIFileProtocolHandler = Ci.nsIFileProtocolHandler;
                            
                            var Process = Cc['@mozilla.org/process/util;1'].createInstance(nsIProcess);
                            var LocalFile = Cc['@mozilla.org/file/local;1'].createInstance(nsILocalFile);
                            var IOService = Cc['@mozilla.org/network/io-service;1'].createInstance(nsIIOService);
                            var FileProtocolHandler = IOService.getProtocolHandler('file').QueryInterface(nsIFileProtocolHandler);
                        } catch(e) {
                            alert('Select Allow to run.');
                            return false;
                        }
                        var file = FileProtocolHandler.getFileFromURLSpec(path);
                        LocalFile.initWithPath(file.path);
                        //LocalFile.leafName, LocalFile.fileSize, LocalFile.exists(), LocalFile.isWritable(), LocalFile.isReadable(), LocalFile.isDirectory(), LocalFile.isFile()
                        if (LocalFile.exists()) {
                            if (!LocalFile.isDirectory()) {
                                try {
                                    Process.init(LocalFile);
                                    Process.run(false, null, 0);
                                } catch(e) {
                                    alert('Operation canceled!');
                                } finally {
                                    localFile._prevent(event);
                                }
                            }
                        } else {
                            alert('Does not exist!');
                            localFile._prevent(event);
                        }
                    },
                    _prevent: function(event) {
                        event.preventDefault();
                        event.stopPropagation();
                    }
                };
                window.addEventListener('DOMContentLoaded', localFile.init, false);
            }
        </script>
    </head>
    <body>
        <div>
            <p><strong>Sample:</strong></p>
            <p><a href="file://///192.168.35.68/Users/DBoskic/Desktop/Test.doc">Document</a></p>
            <p><a href="file://///192.168.35.68/Users/DBoskic/Desktop/Test.exe">Application</a></p>
            <!--if file, hostname or IP does not exist it may took a while to check-->
            <p><a href="http://www.google.com/">Normal URI</a></p>
        </div>
    </body>
</html>
Jako je bitno da
Kôd:
signed.applets.codebase_principal_support
u about:config ima vrednost true.
__________________
In brightest day, in blackest night ...
35-68 je offline   Odgovorite uz citat