Hello,
I'm trying to learn Javascript and im obviosly having some difficulties with the document.getElementById to replace HTML. In the real page there is a function to determine the variable for streama based on the URL etc etc... but the function works perfectly so i have simplified it for the sake of this issue to just defining the variable. Despite all the tutorials and examples i can find I cant see to see the problem with the way i wrote this... the current output is the following...
Watch live video from No Stream on www.twitch.tv
theerebus
As you can probly tell by the script the intene
Watch live video from theerebus on www.twitch.tv
theerebus
Code:<!DOCTYPE html> <html> <body> <script> var streama = "theerebus"; document.getElementById("stream1").href="http://www.twitch.tv/"; document.getElementById("s").innerHTML="Watch live video from " + streama + " on www.twitch.tv"; </script> <a href="http://www.twitch.tv/Nostream" class="trk" id="s" style="padding:2px 0px 4px; display:block; width:345px; font-weight:normal; font-size:10px; text-decoration:underline; text-align:center;">Watch live video from No Stream on www.twitch.tv</a> <script> document.write(streama); </script> </body> </html>


Reply With Quote
Bookmarks