Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   External java file not loadin image (https://www.askmehelpdesk.com/showthread.php?t=339583)

  • Apr 9, 2009, 02:11 PM
    neto1337
    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! :)
  • Apr 9, 2009, 06:04 PM
    robertva

    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.

  • All times are GMT -7. The time now is 06:51 AM.