Uwe Molzahn: Dynamische Links (Crossbrowser)

Beitrag lesen

Hallo nochmal,

fuer den Explorer kann ich jetzt 'ne Loesung anbieten:

<SCRIPT LANGUAGE="JavaScript">
<!--
ie = (document.all)? true:false
function changelink(){
if (ie) parent.document.all.area1.setAttribute("href","LinkNeu.htm","false")
}
//-->
</SCRIPT>

Die entsprechende Area auf der Image Map traegt hier die ID="area1" . Wichtig ist das "parent " vorweg, sonst gibt es einen Laufzeitfehler. Das Link auf dem IFrame wird mit <a href="javascript:changelink()">Link</a> referenziert.

Fuer Netscape scheint es mangels setAttribute Verfügbarkeit wohl nur die Lösung zu geben, weitere Layers im Hauptdokument zu generieren.

Im Web hab' ich übrigens noch 'nen ganz interessanten Lösungsansatz gefunden:

<!-- ONE STEP TO INSTALL DYNAMIC LINKS:

1.  Copy the coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the BODY of your HTML document  -->

<center>
<form name="addresses">
do you want to ... <select name="list" onchange="update()">
<option value="mailto:admin@some-site.com">email admin@some-site.com
<option value="mailto:support@some-site.com">email support@some-site.com
<option value="http://www.netscape.com">go to www.netscape.com
</select>
<a href="updatelink">do it!</a>
</form>
</center>

<script language="javascript">

<!-- this script and many more are available free online at -->
<!-- the javascript source!! http://javascript.internet.com -->

<!--  begin
pos = 9999;
for(num=0;num<document.links.length;num++) {
if (document.links[num].href.indexof("updatelink") != -1) {
pos = num;
num = 5000;
   }
}
function update() {
if (pos!=9999) {
sel = document.addresses.list.selectedindex;
document.links[pos].href = document.addresses.list[sel].value;
   }
}
update();
// end -->
</script>