Sven Rautenberg: target="bla" funzt bei frameset nicht!?

Beitrag lesen

Moin!

Hi versuchs mal damit:

<form>
<select name="to" size="1" onchange="javascript:parent.frames['Mitte'].location = this.form.to.options[this.form.to.selectedIndex].value;">
<option value="bla.htm">bls</option>
</select>
</form>

Du schreibst jetzt zur Strafe hundertmal:

"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
"Es heißt location.href!"
...

"location" ist ein Objekt, welches nicht direkt geändert werden kann. Es hat aber verschiedene Eigenschaften, die man ändern kann, unter anderem die URL. Man kann dort auch andere Dinge abfragen, wie z.B. den Suchparameter, den Hostnamen oder das verwendete Protokoll (steht zwar alles auch in location.href, aber dann müßte man es manuell vereinzeln).

Ein weiterer beliebter Fehler: document.location.href
Ist genauso falsch, weil location ein Unterobjekt von window ist, nicht von window.document :) .

- Sven Rautenberg