PDA

View Full Version : Why doesn't this work



maddoccanis
02-14-2014, 08:05 PM
I dont know how to post this properly. I have written code for a long time, but am ne to javascript. Why doesn't this work?


</head>
<body>
<script type="text/javascript">
var headSrc="http://www."
var pathName="megeddo.nightsplutonianshore.com/";
var alienDoc="aliendoc01.gif"
document.write(headSrc + pathName + alienDoc);
</script>
<img src=headSrc + pathName + alienDoc width="344" height="222" alt="ace" title="" />
</body>

traq
02-14-2014, 09:37 PM
Your question is unclear.
Please provide more information, and be as specific as possible.
What do you want to accomplish? What have you already tried? What problems did you encounter?
Please be sure that you have included all relevant code and/or a link to the page in question.
You might also consider making a reduced test case (http://css-tricks.com/reduced-test-cases/) using an online tool like jsfiddle (http://jsfiddle.net)

jscheuer1
02-15-2014, 06:04 AM
I agree that it's unclear what you're asking. But this might be the answer:


</head>
<body>
<script type="text/javascript">
var headSrc="http://www."
var pathName="megeddo.nightsplutonianshore.com/";
var alienDoc="aliendoc01.gif";
document.write('<img src="' + headSrc + pathName + alienDoc + '" width="344" height="222" alt="ace" title="" />');
</script>

</body>

maddoccanis
02-15-2014, 04:39 PM
i have a lot of images with long src strings. i just wanted to put the bulk of this in a variable to simplify code