WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   js links (http://www.wcm.at/forum/showthread.php?t=227452)

mqs 21.03.2008 11:05

js links
 
hallo!
ist es möglich per js eine url in einem <a href="url"> zu ändern?
und zwar per klick (onClick)
hab das mit bildern geschafft bzw ein script gefunden und angepasst. sieht folgend aus:

Code:

var Pic= new Array();
Pic[1]="bild1.jpg"
Pic[2]="bild2.jpg"
Pic[3]="bild3.jpg"

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
  preLoad[i] = new Image()
  preLoad[i].src = Pic[i]
}

function displaySS(ImgNumber){
  if (document.all){
      document.images.SSImg.style.filter="blendTrans(duration=2)";
      document.images.SSImg.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SSImg.filters.blendTrans.Apply();
  }
  document.images.SSImg.src = preLoad[ImgNumber].src;
 
  if (document.all){
      document.images.SSImg.filters.blendTrans.Play()
  }
}

ich will nun dass sich mit dem bild auch der link ändert
wie funktioniert das?

zAPPEL 21.03.2008 11:37

Code:

<script type="text/javascript">
function changeLink()
{
        document.getElementById('myLink').innerHTML="WebSewak";
        document.getElementById('myLink').href="http://www.websewak.com";
        document.getElementById('myLink').target="_blank";
}
</script>

(3 sek. Google-Suche..)

lg

mqs 21.03.2008 11:54

super danke..werd das dann gleich mal testen.

(du weisst ja nach was du suchen musst ;) ich code normal nichts in js, kenn mich da zuwenig aus)

danke!


Alle Zeitangaben in WEZ +2. Es ist jetzt 05:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag