Log in

View Full Version : Java Help


The Ninja
January 8th, 2011, 09:54 PM
This is the code I'm using:

<html>
<body>

<script type="text/javascript">
var img="URL/FILE";
document.write("<img src="+img+"/>");
</script>

</body>
</html>


This is what I'm using to test it:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_basic

It's not displaying the image just a blank page.

Can anyone tell me what I'm doing wrong? +rep for the best/first answer.

Commander Thor
January 8th, 2011, 10:11 PM
In the <img> tag, you need a space between the " and the />".
So the code should look like:

<html>
<body>
<script type="text/javascript">
var img = "IMG/URL";
document.write("<img src="+img+" />");
</script>
</body>
</html>


(I underlined the bit you messed up.)

The Ninja
January 8th, 2011, 10:13 PM
In the <img> tag, you need a space between the " and the />".
So the code should look like:

<html>
<body>
<script type="text/javascript">
var img = "IMG/URL";
document.write("<img src="+img+" />");
</script>
</body>
</html>


(I underlined the bit you messed up.)

OMFG. Thank-you so much for helping this noob in distress. +rep

ERM it's not letting me give you rep. It says I have to "spread some around" before I can give you any. Have i given you too much rep or something.

Commander Thor
January 8th, 2011, 10:15 PM
Heh, no problem mate.
You actually had me stumped there for a bit, I couldn't figure out why it wasn't working either, then I noticed it..... :p

Edit: As far as I can tell, this is the last rep you gave me: http://www.virtualteen.org/forums/showthread.php?p=1091385#post1091385
If you haven't given any other rep (I think you have to give rep to 10 other people before you can give it back to someone), then you can't +rep me yet.
Though I don't really care, it's the thought that counts. :) (And the help I gave you that counts even more)
Edit2: Besides, I don't do it for the rep. I do it because I like helping people.