Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[JavaScript] Event-Objekt abfragen in nicht-IE?

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe folgenden Quelltext:


...

<script language="JavaScript">

...

function displayMenu()

{

  whichDiv=event.srcElement;

  ...

}

...

</script>

...

<textarea cols=80" rows="5" name="comment" oncontextmenu="displayMenu(); return false;">

...

das heisst, ich möchte, wenn ich mit der Maus auf dem Textfeld einen Rechtsklick mache, soll er mir statt des Kontextmenüs ein Menü anzeigen, welches abhängig vom "angeklickten" Textfeld ist. Unter dem IE funktioniert das auch prima. Aber auf anderen (z.B. Firefox) kommt die Fehlermeldung, dass das event-Objekt nicht definiert wäre. Nach einigem Suchen habe ich folgendes ausprobiert:

function displayMenu(e)

{

  if (!e) e=window.event;

  whichDiv = e.srcElement;

 ...

}

Funktioniert aber auch nicht.

Fehlermeldung (firefox): e has no properties

Mit dem IE funktioniert es so immer noch.

Hat jemand eine Idee, wie ich mit dem firefox herausbekomme, von welchem Element der Event ausgelöst wurde?

Grundsätzlich: Firefox (und andere Browser) blockieren die Abfrage des Rechtsklicks. Manchmal Schade, ist aber so. daher kannst du dir das schonmal abschminken.

Ich glaube was Firefox und event angeht, da hängt das auch von groß/kleinschreibung ab..versuchmal "Event" .hab gerade meine Scripts nicht zur hand...ich kann da nachher noch was zu posten...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.