SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code show up on website itself. [Code Review]

    Hello! I am having some trouble getting my information to show up.
    At first it shows the table with the information, and then it shows a syntax error, and the information I just entered to be a document ready command.
    All of the information I have, except for the table, is coming from the book pg. 20 of the second edition, but I can't figure out what I am doing wrong.
    When I view this code in a browser while having a syntax error, I cannot see anything.
    And when I do not have an error, I get the code that I just entered stuck in my webpage at the top.

    Here is the entire code that I am having trouble with.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>The Cake Kiosk</title>
    <script type="text/javascript" src="jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="script.js"></script>
    $(document).ready(function(){
      alert('Welcome to StarTrackr! Now no longer under police investigation!');
    });
    
    </head>
    
    <body>
    
    <table width="100%" border="2" cellspacing="2" cellpadding="2" bgcolor="#0066FF">
      <tr>
        <td colspan="2" align="center">The Cake Kiosk</td>
       
      </tr>
      <tr>
        <td align="center">Design Your Own</td>
        <td align="center">Current Designs</td>
      </tr>
      <tr>
        <td align="center">Java Script Code Left</td>
        <td align="center">Java Script Code Right</td>
      </tr>
       <tr>
        <td align="center" colspan="2">Developed by Kiosks for Cakes</td>
       
      </tr>
    </table>
    
    </body>
    </html>
    Thank you for your time!
    Last edited by Force Flow; Aug 21, 2012 at 13:37. Reason: added [code] tags

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Looks like the problem you're having in this case is that your JavaScript underneath the "script.js" line is not actually inside script tags. This means the browser won't evaluate it as JavaScript and probably thinks it's some malformed HTML.

    If you were to place your $(document).ready() block in to script.js or wrap it with script tags, it should work
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YES! Thank you so very much!!!! I put into the end of the script.js tag first, and it didn't do anything except take the line off the actual webpage. Then I put it into it's own script tags and it worked just fine. I am assuming that because I put it in <script> tags that it treated it as script?

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Polcat View Post
    YES! Thank you so very much!!!! I put into the end of the script.js tag first, and it didn't do anything except take the line off the actual webpage. Then I put it into it's own script tags and it worked just fine. I am assuming that because I put it in <script> tags that it treated it as script?
    Yes, your assumption is correct.

  5. #5
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweet! this is so much fun! getting it wrong and then fixing it is just as much fun as getting it right the first time!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •