Nur mal auf die Schnelle:<BR>NN4.08 nimmt's nicht, opera5.02 nimmt's nicht, NN6.1 macht eher lustige Sachen, soll<BR>heißen: onmousedown und währenddessen rüberrutschen auf's menu, und das Ding bleibt erhalten. Einfach nur klicken und nicht gleichzeitig drübergehen, und das menu verschwindet sofort wieder. Auch bekomme ich manchmal - und manchmal auch wieder nicht - die Fehlermeldung:<P>Fehler: redeclaration of const kIOServiceProgID<BR>Quelldatei: chrome://communicator/content/utilityOverlay.js<P>Jedenfalls ist mir bisher unklar, von welchem<BR>Event das ausgelöst wird. Hier mal die Quelldatei:<P>/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-<BR> *<BR> * The contents of this file are subject to the Netscape Public<BR> * License Version 1.1 (the "License"); you may not use this file<BR> * except in compliance with the License. You may obtain a copy of<BR> * the License at <A HREF="http://www.mozilla.org/NPL/" TARGET=_blank>http://www.mozilla.org/NPL/</A> <BR> *<BR> * Software distributed under the License is distributed on an "AS<BR> * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or<BR> * implied. See the License for the specific language governing<BR> * rights and limitations under the License.<BR> *<BR> * The Original Code is mozilla.org code.<BR> *<BR> * The Initial Developer of the Original Code is Netscape<BR> * Communications Corporation. Portions created by Netscape are<BR> * Copyright (C) 1998 Netscape Communications Corporation. All<BR> * Rights Reserved.<BR> *<BR> * Contributor(s):<BR> * Alec Flett <alecf@netscape.com><BR>*/<P>/**<BR> * Communicator Shared Utility Library<BR> * for shared application glue for the Communicator suite of applications<BR> **/<P>/**<BR> * Go into online/offline mode<BR> **/<P>const kIOServiceProgID = "@mozilla.org/network/io-service;1";<BR>const kObserverServiceProgID = "@mozilla.org/observer-service;1";<P>function toggleOfflineStatus()<BR>{<BR> var checkfunc;<BR> try {<BR> checkfunc = document.getElementById("offline-status").getAttribute('checkfunc');<BR> }<BR> catch (ex) {<BR> checkfunc = null;<BR> }<P> var ioService = Components.classes[kIOServiceProgID]<BR> .getService(Components.interfaces.nsIIOService);<BR> if (checkfunc) {<BR> if (!eval(checkfunc)) {<BR> // the pre-offline check function returned false, so don't go offline<BR> return;<BR> }<BR> }<BR> ioService.offline = !ioService.offline;<BR>}<P>function setOfflineUI(offline)<BR>{<BR> var broadcaster = document.getElementById("Communicator:WorkMode");<BR> if (!broadcaster) return;<P> //Checking for a preference "network.online", if it's locked, disabling <BR> // network icon and menu item<BR> var prefService = Components.classes["@mozilla.org/preferences-service;1"];<BR> prefService = prefService.getService();<BR> prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);<BR> <BR> var prefBranch = prefService.getBranch(null);<BR> <BR> var offlineLocked = prefBranch.prefIsLocked("network.online"); <BR> <BR> if (offlineLocked ) {<BR> broadcaster.setAttribute("disabled","true");<BR> }<P> var bundle = srGetStrBundle("chrome://communicator/locale/utilityOverlay.properties");<P> if (offline)<BR> {<BR> broadcaster.setAttribute("offline", "true");<BR> broadcaster.setAttribute("tooltiptext", bundle.GetStringFromName("offlineTooltip"));<BR> broadcaster.setAttribute("label", bundle.GetStringFromName("goonline"));<BR> FillInTooltip(broadcaster);<BR> }<BR> else<BR> {<BR> broadcaster.removeAttribute("offline");<BR> broadcaster.setAttribute("tooltiptext", bundle.GetStringFromName("onlineTooltip"));<BR> broadcaster.setAttribute("label", bundle.GetStringFromName("gooffline"));<BR> FillInTooltip(broadcaster);<BR> }<BR>}<P>var goPrefWindow = 0;<P>function getBrowserURL() {<P> try {<BR> var prefs = Components.classes["@mozilla.org/preferences;1"];<BR> if (prefs) {<BR> prefs = prefs.getService();<BR> if (prefs)<BR> prefs = prefs.QueryInterface(Components.interfaces.nsIPref);<BR> }<BR> if (prefs) {<BR> var url = prefs.CopyCharPref("browser.chromeURL");<BR> if (url)<BR> return url;<BR> }<BR> } catch(e) {<BR> }<BR> return "chrome://navigator/content/navigator.xul";<BR>}<P>function goPageSetup()<BR>{<BR>}<P>function goEditCardDialog(abURI, card, okCallback, abCardURI)<BR>{<BR> window.openDialog("chrome://messenger/content/addressbook/abEditCardDialog.xul",<BR> "",<BR> "chrome,resizeable=no,modal,titlebar",<BR> {abURI:abURI, card:card, okCallback [img]images/icons/blush.gif" border="0[/img]kCallback, abCardURI:abCardURI});<BR>}<P>function goPreferences(containerID, paneURL, itemID)<BR>{<BR> var resizable;<BR> var pref = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);<BR> <BR> try {<BR> // We are resizable ONLY if in box debugging mode, because in<BR> // this special debug mode it is often impossible to see the <BR> // content of the debug panel in order to disable debug mode.<BR> resizable = pref.GetBoolPref("xul.debug.box");<BR> }<BR> catch (e) {<BR> resizable = false;<BR> }<P> var resizability = "yes"; // resizable ? "yes" : "no";<BR> var features = "chrome,titlebar,resizable=" + resizability;<BR> openDialog("chrome://communicator/content/pref/pref.xul","PrefWindow", <BR> features, paneURL, containerID, itemID);<BR>}<P>function goToggleToolbar( id, elementID )<BR>{<BR> var toolbar = document.getElementById( id );<BR> var element = document.getElementById( elementID );<BR> if ( toolbar )<BR> {<BR> var attribValue = toolbar.getAttribute("hidden") ;<P> if ( attribValue == "true" )<BR> {<BR> toolbar.setAttribute("hidden", "false" );<BR> if ( element )<BR> element.setAttribute("checked","true")<BR> }<BR> else<BR> {<BR> toolbar.setAttribute("hidden", true );<BR> if ( element )<BR> element.setAttribute("checked","false")<BR> }<BR> document.persist(id, 'hidden');<BR> document.persist(elementID, 'checked');<BR> }<BR>}<P><BR>function goClickThrobber( urlPref )<BR>{<BR> var url;<BR> try {<BR> var pref = Components.classes["@mozilla.org/preferences;1"].getService();<BR> if( pref )<BR> pref = pref.QueryInterface( Components.interfaces.nsIPref );<BR> url = pref.getLocalizedUnicharPref(urlPref);<BR> }<P> catch(e) {<BR> url = null;<BR> }<P> if ( url )<BR> openTopWin(url);<BR>}<P><BR>//No longer needed. Rip this out since we are using openTopWin<BR>function goHelpMenu( url )<BR>{<BR> /* note that this chrome url should probably change to not have all of the navigator controls */<BR> /* also, do we want to limit the number of help windows that can be spawned? */<BR> window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );<BR>}<P><BR>function openTopWin( url )<BR>{<BR> /* note that this chrome url should probably change to not have all of the navigator controls,<BR> but if we do this we need to have the option for chrome controls because goClickThrobber()<BR> needs to use this function with chrome controls */<BR> /* also, do we want to limit the number of help windows that can be spawned? */<BR> if ((url == null) || (url == "")) return;<P> // xlate the URL if necessary<BR> if (url.indexOf("urn:") == 0)<BR> {<BR> url = xlateURL(url); // does RDF urn expansion<BR> }<P> // avoid loading "", since this loads a directory listing<BR> if (url == "") {<BR> url = "about:blank";<BR> }<P> var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();<BR> var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);<P> var topWindowOfType = windowManagerInterface.getMostRecentWindow( "navigator:browser" );<BR> if ( topWindowOfType )<BR> {<BR> topWindowOfType.focus();<BR> topWindowOfType._content.location.href = url;<BR> }<BR> else<BR> {<BR> window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );<BR> }<BR>}<P>function goAboutDialog()<BR>{<BR> var defaultAboutState = false;<BR> try {<BR> var pref = Components.classes["@mozilla.org/preferences;1"].getService();<BR> if( pref )<BR> pref = pref.QueryInterface( Components.interfaces.nsIPref );<BR> defaultAboutState = pref.GetBoolPref("browser.show_about_as_stupid_modal_window");<BR> }<BR> catch(e) {<BR> defaultAboutState = false;<BR> }<BR> if( defaultAboutState )<BR> window.openDialog("chrome:global/content/about.xul", "About", "modal,chrome,resizable=yes,height=450,width=550");<BR> else<BR> window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", 'about:' );<BR>}<P>// update menu items that rely on focus<BR>function goUpdateGlobalEditMenuItems()<BR>{<BR> goUpdateCommand('cmd_undo');<BR> goUpdateCommand('cmd_redo');<BR> goUpdateCommand('cmd_cut');<BR> goUpdateCommand('cmd_copy');<BR> goUpdateCommand('cmd_paste');<BR> goUpdateCommand('cmd_selectAll');<BR> goUpdateCommand('cmd_delete');<BR>}<P>// update menu items that rely on the current selection<BR>function goUpdateSelectEditMenuItems()<BR>{<BR> goUpdateCommand('cmd_cut');<BR> goUpdateCommand('cmd_copy');<BR> goUpdateCommand('cmd_delete');<BR>}<P>// update menu items that relate to undo/redo<BR>function goUpdateUndoEditMenuItems()<P>{<BR> goUpdateCommand('cmd_undo');<BR> goUpdateCommand('cmd_redo');<BR>}<P>// update menu items that depend on clipboard contents<BR>function goUpdatePasteMenuItems()<BR>{<BR> goUpdateCommand('cmd_paste');<BR>}<P>// This used to be BrowserNewEditorWindow in navigator.js<BR>function NewEditorWindow(aPageURL)<BR>{<BR> // Open editor window with blank page<BR> // Kludge to leverage openDialog non-modal!<BR> window.openDialog( "chrome://editor/content", "_blank", "chrome,all,dialog=no", "about:blank");<BR>}<P>function NewEditorFromTemplate()<BR>{<BR> // XXX not implemented<BR>}<P>function NewEditorFromDraft()<BR>{<BR> // XXX not implemented<BR>}<P>// Any non-editor window wanting to create an editor with a URL<BR>// should use this instead of "window.openDialog..."<BR>// We must always find an existing window with requested URL<BR>// (When calling from a dialog, "launchWindow" is dialog's "opener"<BR>// and we need a delay to let dialog close)<BR>function editPage(url, launchWindow, delay)<BR>{<BR> // User may not have supplied a window<BR> if (!launchWindow)<BR> {<BR> if (window)<BR> {<BR> launchWindow = window;<BR> }<BR> else<BR> {<BR> dump("No window to launch an editor from!n");<BR> return;<BR> }<BR> }<P> var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();<BR> if (!windowManager) return;<BR> var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);<BR> if ( !windowManagerInterface ) return;<BR> var enumerator = windowManagerInterface.getEnumerator( "composer:html" );<BR> if ( !enumerator ) return;<P> while ( enumerator.hasMoreElements() )<BR> {<BR> var window = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() );<BR> if ( window && window.editorShell)<BR> {<BR> if (window.editorShell.checkOpenWindowForURLMatch(url, window))<BR> {<BR> // We found an editor with our url<BR> window.focus();<BR> return;<BR> }<BR> }<BR> }<P> // Create new Composer window<BR> if (delay)<BR> launchWindow.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", url);<BR> else<BR> launchWindow.openDialog("chrome://editor/content", "_blank", "chrome,all,dialog=no", url);<BR>}<P>// function that extracts the filename from a url<BR>function extractFileNameFromUrl(urlstr)<BR>{<BR> if (!urlstr) return null;<BR> return urlstr.slice(urlstr.lastIndexOf( "/" )+1);<BR>}<P>var offlineObserver = {<BR> Observe: function(subject, topic, state) {<BR> // sanity checks<BR> if (topic != "network [img]images/icons/blush.gif" border="0[/img]ffline-status-changed") return;<BR> setOfflineUI(state == "offline");<BR> }<BR>}<P>function utilityOnLoad(aEvent)<BR>{<BR> var broadcaster = document.getElementById("Communicator:WorkMode");<BR> if (!broadcaster) return;<P> var observerService = Components.classes[kObserverServiceProgID]<BR> .getService(Components.interfaces.nsIObserverService);<P> // crude way to prevent registering twice.<BR> try {<BR> observerService.RemoveObserver(offlineObserver, "network [img]images/icons/blush.gif" border="0[/img]ffline-status-changed");<BR> }<BR> catch (ex) {<BR> }<BR> observerService.AddObserver(offlineObserver, "network [img]images/icons/blush.gif" border="0[/img]ffline-status-changed");<BR> // make sure we remove this observer later<BR> addEventListener("unload",utilityOnUnload,false);<P> // set the initial state<BR> var ioService = Components.classes[kIOServiceProgID]<BR> .getService(Components.interfaces.nsIIOService);<BR> setOfflineUI(ioService.offline);<BR>}<P>function utilityOnUnload(aEvent) <BR>{<BR> var observerService = Components.classes[kObserverServiceProgID]<BR> .getService(Components.interfaces.nsIObserverService);<BR> observerService.RemoveObserver(offlineObserver, "network [img]images/icons/blush.gif" border="0[/img]ffline-status-changed");<BR>}<P>addEventListener("load",utilityOnLoad,true);<P>Vielleicht kannst Du damit was anfangen, mir ist's momentan nebulös. Allerdings hatte ich diese Fehlermeldung auch schon bei andren Scripts, und zwar immer dann, wenn ich auf Quelltext anzeigen gegangen bin. Möglicherweise ist's ein Fehler netscapeseitig.<BR>Ich glaube auch, daß es das return false zum Unterdrücken nicht braucht.<P>gruß <P>matho