Klaus Junge: NC Fehler bei document.writeln???

Beitrag lesen

Hallo Götz!

in einer älteren JavaScript-Referenz habe ich folgende Passage gefunden:


Using quotation marks

Use single quotation marks ( ' ) to delimit string literals so that scripts can distinguish the literal
from attribute values enclosed in double quotation marks. In the following example, the function
bar contains the literal "left" within a double-quoted attribute value:

function bar(widthPct) {
          document.write("<HR ALIGN='left' WIDTH=" + widthPct + "%>")
}

Here's another example:

<INPUT TYPE="button" VALUE="Press Me" onClick="myfunc('astring')">

Be sure to alternate double quotation marks with single quotation marks. Because event
handlers in HTML must be enclosed in quotation marks, you must use single quotation marks
to delimit string arguments. For example:

<FORM NAME="myform">
<INPUT TYPE="button" NAME="Button1" VALUE="Open Sesame!"
          onClick="window.open('mydoc.html', 'newWin')">
</FORM>


Demnach sind Attributwerte in doppelten und Literals (=wörtlich einzusetzende Begriffe)
in einfachen Gänsefüßchen zu setzen.
Hoffentlich bringt das etwas Klärung.

Klaus