Ask Experts Questions for FREE Help !
Ask
    neto1337's Avatar
    neto1337 Posts: 1, Reputation: 1
    New Member
     
    #1

    Apr 9, 2009, 02:11 PM
    external java file not loadin image
    Hi, I am making my first website, blog. This website is all in html and I want to change a part of it to java to only have to change one file to modify the content on every page.

    I used this html to java converter: Cut & Paste HTML to JavaScript converter.

    What I tried to convert is the about me section at Neto's Place. Everything works find except the picture which is not loaded. Can anyone help me fix this?

    here is the original html:
    <!-- Right column -->
    <div id="col" class="noprint">
    <div id="col-in">

    <!-- About Me -->
    <h3><span><a href="/aboutme.html">About Me</a></span></h3>

    <div id="about-me">
    <p><img src="images/me2.bmp" id="me" alt="Yeah, its me!" />
    <strong>Ernesto Rodriguez Leyva</strong><br />
    Age: 21<br />
    <br />
    <a href="/index.html">www.netoforum.com</a></p>
    </div> <!-- /about-me -->

    Here is what it looks like now in my html document:

    <!-- Right column -->
    <div id="col" class="noprint">
    <div id="col-in">

    <script type="text/javascript" src="testing1.js" >
    </script>


    Here is that testing.js looks like:

    info="<h3><span><a href=&#34;/aboutme.html&#34;>About Me</a></span></h3>" +
    "" +
    " <div id=&#34;about-me&#34;>" +
    " <p><img src=&#34;images/me2.bmp&#34; id=&#34;me&#34; alt=&#34;Yeah, its me!&#34; />" +
    " <strong>Ernesto Rodriguez Leyva</strong><br />" +
    " Age: 21<br />" +
    " <br />" +
    " <a href=&#34;/index.html&#34;>www.netoforum.com</a></p>"

    document.write(info)

    Thanks! :)
    robertva's Avatar
    robertva Posts: 249, Reputation: 30
    Full Member
     
    #2

    Apr 9, 2009, 06:04 PM

    At lot of people get confused about the similar names of Java and Javascript. Java is a form of code that's compiled and downloaded from the server as a separate file (usually with a .jar extension) containing Java virtual machine code that wouldn't normally be readable for humans. It was intended for interactive page elements like web mail or web games, but many sites are now using Adobe Flash or ActiveX for those purposes. Sites utilizing ActiveX might require an add-on for full compatibility with browsers other than Internet Explorer though.

    Look at the first line in your Javascript. As soon as the Javascript interpreter gets to that second quotation mark (after href=) it figures you've completed the info variable assignment. There being no concatenation operator after that quotation mark the Javascript interpreter is looking immediately for a separator (semicolon) signaling the beginning of another assignment or Javascript command.

    Try preceding each of the double quotation marks in your assignment that you intend to become part of your string (like the ones after href= , src= .html, bmp, id= etc) with a backslash (\). That should make the Javascript interpreter add the double quote to your string instead of terminating the string variable assignment.

    info="<h3><span><a href=\"/aboutme.html\">About Me</a></span></h3>"

    You might need to make your assignment/concactination a single very long line to work properly. I'm unable to verify that's what you're already doing because the board would wrap a single line to display as multiple lines.

    Since there's nothing but the span element inside the h3 element I think it's probably redundant and could be eliminated.

    There's one point with an empty string ("") that seems pointless. I'm thinking you meant to type a space in that location.

    Like many programming languages Javascript needs semicolons between commands. You should add a semicolon between the end of your string concatenation and the document.write() command.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Convert image (pdf, typewriter text) to text file [ 21 Answers ]

I've played with 3 different OCR apps (including one that seems to be tops (Abbyy Fine Reader Pro) and find it too much. Easy to use but far too time consuming for my skills with it. See the attached pdf (38 pages of typed text). I have it and 5 others that need converted but am finding it too...

Playstation 3 external hard drive game utility file transfers [ 1 Answers ]

I've connected a 500GB external hard drive to my 40GB PS3 and can transfer files back and forth from it, but how do I transfer actual game utility back and forth or downloaded games. I can only seem to delete them or do a whole system backup. Is there anyway to pick what to transfer or am I going...

.net or Java [ 2 Answers ]

Hi I have done B.Sc IT and of lately I have been thinking of doing .net and Java.Which one should I do?? Please let me know. Thanks and regards Dharamvir Bhandari


View more questions Search