Jan: Area coords von Map dynamisch

Ist es möglich (im IE) die Koordinaten einer Map-Area mit Javascript (oder  anders) zu ändern?
Würde mir auch helfen, wenn man Sie vom Browser abhängig macht, also für den IE 'ne andere Map-Area als für Netscape.
Ist es im IE vielleicht möglich mit document.[...].coords="..." den Bereich festzulegen oder zu ändern?

  1. Hallo Jan,

    Ist es möglich (im IE) die Koordinaten einer Map-Area mit Javascript (oder  anders) zu ändern?

    Beim MSIE kannst du alles aendern, alle Attribute, alle Tags, und zwar ueber das all-Objekt (siehe <../../tecbba.htm>).
    Bei Netscape wuesste ich jetzt keinen Weg dafuer. Ueber das links-Objekt jedenfalls ist meines Wissens kein Zugriff auf die coords moeglich.

    viele Gruesse
      Stefan Muenz

    1. Hallo Stefan,

      Beim MSIE kannst du alles aendern, alle Attribute, alle Tags, und zwar ueber das all-Objekt (siehe <../../tecbba.htm>).

      <script language="javascript">
      if (navigator.appName == 'Microsoft Internet Explorer')
      document.all.area1.coords="...";
      </script>

      <body>
      ...
      <map id="map1">
      <area id="area1" shape=polygon coords="..." href="link.htm">
      </map>
      ...
      </body>

      Hatte ich bereits versucht (siehe Quellcode), doch es kommt immer die Scriptfehler-Meldung:
      "document.all.area1 ist kein Objekt". Mit

      <script language="javascript">
      if (navigator.appName == 'Microsoft Internet Explorer')
      document.all.tags("area")[0].coords="...";
      </script>

      passiert das gleiche. Was ist mein Fehler?

      viele Gruesse
        jan

      1. Hallo Jan,

        <script language="javascript">
        if (navigator.appName == 'Microsoft Internet Explorer')

        »»  document.all.area1.coords="...";

        </script>
        Was ist mein Fehler?

        Tja, du musst halt entsprechende Eigenschaften oder Methoden des all-Objekts anwenden. Um ein HTML-Tag z.B. komplett zu ersetzen, kannst du die Eigenschaft outerHTML anwenden, z.B. document.all.area1.coords.outerHTML="<area .... usw.>" + document.all.area1.coords.outerHTML + "</area>", fuer einzelne Attribute wie coords z.B. die Methode setAttribtute(), z.B. document.all.area1.coords.setAttribtute("coords","0,0,100,100","false")

        viele Gruesse
          Stefan Muenz

        1. Hallo Stefan,

          Mit outerHTML hab ich es nicht hinbekommen. Ging dann aber mit setAttribute.
          Übrigens: Cut&Paste ist Müll. Man übersieht wichtige Tippfehler so schnell:

          Funktionierte zuerst nicht, weil Du
          document.all.area1.coords.setAttribtute("coords","0,0,100,100","false")
          statt
          document.all.area1.setAttribute("coords","0,0,100,100","false")
          geschrieben hast.

          Vielen Dank und Gruesse
            Jan

  2. Hallo Jan,Stefan,

    Ist es möglich (im IE) die Koordinaten einer Map-Area mit Javascript (oder  anders) zu ändern?

    da gab es doch auch noch diese Entities. Würden die da etwas bringen?
    Kapiert hab' ich die noch nicht so recht, aber benutzt schon. ;-)(
    In einem JS-Tutorial von NS habe ich folgendes gefunden:

    Using JavaScript expressions as HTML attribute values

    Using JavaScript entities, you can specify a JavaScript expression as the value for an
    HTML attribute.
    Entity values are evaluated dynamically. This allows you to create more flexible
    HTML constructs, because the attributes of one HTML element can depend on
    information about elements placed previously on the page.

    You may already be familiar with HTML character entities by which you can define
    characters with special numerical codes or names by preceding the name with an
    ampersand (&) and terminating it with a semicolon (;). For example, you can include
    a greater-than symbol (>) with the character entity > and a less-than symbol (<)
    with <.

    JavaScript entities also start with an ampersand (&) and end with a semicolon (;).
    Instead of a name or number, you use a JavaScript expression enclosed in curly
    braces {}. You can use JavaScript entities only where an HTML attribute value
    would normally go. For example, suppose you define a variable barWidth.
    You could create a horizontal rule with the specified percentage width as follows:

    <HR WIDTH="&{barWidth};%" ALIGN="LEFT">

    So, for example, if barWidth were 50, this would create the following display:

    ...

    Klaus