tolja
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору ChVL Возьми мой ieviewOverlay.js и замени им свой, посмотри,что из этого получиться. Код: /* * * Copyright (c) 2003 Paul Roub <paul@roub.net> * * Portions based on GPLed code by * Ted Mielczarek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***** * * Notes: * * Since we can't know ahead of time where IE will be installed, we Kiboze the * Start Menu tree. If the shortcut has been renamed (i.e. it is no longer * titled "Internet Explorer"), we're out of luck. The only option at that * point would be to open and dereference every symlink we find, and see if the * target leaf name is "iexplore.exe". Not doing that at the moment, since * it just seems insane. */ var ieviewMenuItems = new Array("ieview-do-view", "ieview-do-viewlink"); var userPrograms = "Progs"; var allUserPrograms = "CmPrgs"; var applicationData = "AppData"; var gIeViewBundle; function ieviewContext() { if(gContextMenu) { for(var i=0; i<ieviewMenuItems.length; i++) { var menuitem = document.getElementById(ieviewMenuItems[i]); if(menuitem && (i == 0)) menuitem.hidden = (gContextMenu.isTextSelected || gContextMenu.onLink || gContextMenu.onImage || gContextMenu.onTextInput ); else if (menuitem) { menuitem.hidden = ! gContextMenu.onLink; } } } } function ieView() { if(gContextMenu) { var href = gBrowser.currentURI.spec; ieViewLaunch("Internet Explorer.lnk", href); } } function ieViewLink() { if(gContextMenu) { var href = gContextMenu.linkURL(); ieViewLaunch("Internet Explorer.lnk", href); } } // attempt to grab the real path of a predefined directory // function tryDir(dsp, key) { try { var nif = dsp.get(key, Components.interfaces.nsIFile); return(nif.path); } catch (ar) { return(""); } } function searchPath(path, fname) { var result = null; try { var f = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); f.initWithPath(path); if (f.exists() && f.isDirectory()) { var entries = f.directoryEntries; while (entries.hasMoreElements()) { var ent = entries.getNext().QueryInterface(Components.interfaces.nsIFile); if (ent.isDirectory()) { result = searchPath(ent.path, fname); if (result) { break; } } else if (ent.isSymlink()) { if (ent.leafName == fname) { result = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); result.followLinks = true; result.initWithPath(ent.path); break; } } } } } catch (ar) { return(null); } return( result ); } function ieViewLaunch (path,argumentstext) { var cantMessage = gIeViewBundle.getString("cantFindExplorer"); try{ if(path=="") return false; var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess); var dsprops = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties); var usePath = tryDir(dsprops, userPrograms); // try user-specific program menu first var file = null; if (usePath != "") { file = searchPath(usePath, path); } if (! file) { usePath = tryDir(dsprops, allUserPrograms); // no joy? try "all users" program menu if (usePath != "") { file = searchPath(usePath, path); } } if (! file) { usePath = tryDir(dsprops, applicationData); // last resort, check the "quick start" bar if (usePath != "") { var quickPath = "\\microsoft\\internet explorer\\quick launch"; usePath = usePath + quickPath; file = searchPath(usePath, path); if (! file) // check alternate QuickLaunch bar title { var launchLink = "Launch Internet Explorer Browser.lnk"; file = searchPath(usePath, launchLink); } } } if ((! file) || (! file.exists())) { alert(cantMessage); return false; } var natTarget; natTarget = file.target; var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); targetFile.initWithPath(natTarget); if (! targetFile.exists()) { alert(cantMessage); return(false); } usePath = targetFile.target; process.init(targetFile); var arguments= [] ; arguments.push(argumentstext); process.run(false, arguments, arguments.length, {}); return true; }catch(e){ alert(e);return false; } return false; // avoid JavaScript Error. } function ieviewInit() { var menu = document.getElementById("contentAreaContextMenu"); menu.addEventListener("popupshowing",ieviewContext,false); gIeViewBundle = document.getElementById("bundle_ieview"); } // do the init on load window.addEventListener("load", ieviewInit, false); | |