www.webdeveloper.com
Results 1 to 14 of 14

Thread: Browser is not displaying Java script

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    15

    Post Browser is not displaying Java script

    Hi everyone)Currently i am learning HTML,CSS and Java script.As we know we don,t need a web server to display html,css and java script on our browsers.Below is the code embedded with a java script which i wanted to display on my browser but it,s not showing the java script which is about displaying the date and time.It just shows the header called "Current Date and Time ".What,s the problem? Please help me if you have a solution to this problem.

    <?xml version=”1.0” encoding=”UTF-8”?>
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
    “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
    <html xmlns=” xml:lang=”en”>
    <head>
    <title>Displaying Times and Dates</title>
    </head>
    <body>
    <h1>Current Date and Time</h1>
    <script type=”text/javascript”>
    now = new Date();
    localtime = now.toString();
    utctime = now.toGMTString();
    document.write(“<strong>Local time:</strong> “
    + localtime + “<br/>”);
    document.write(“<strong>UTC time:</strong> “ + utctime);
    hours = now.getHours();
    mins = now.getMinutes();
    secs = now.getSeconds();
    document.write(“<h1>”);
    document.write(hours + “:” + mins + “:” + secs);
    document.write(“</h1>”);
    </script>
    </body>
    </html>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    if you didn't try to make the code look much sightly and used the proper quote marks this could work
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,223
    What are you using as an editor?

    Suggested editors are plain text ones like notepad and the more advanced notepad++ or a HTML IDE.

    For proper result, yes you do need a webserver, this then ensures any links, files you allow for download, testing of uploads will mean that your code will have everything ready to go and upload to a web server.

    Finally, all web forums have TAGS that allow you to "Wrap" code segments so they are easier to read, please use them.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    15
    Quote Originally Posted by \\.\ View Post
    What are you using as an editor?

    Suggested editors are plain text ones like notepad and the more advanced notepad++ or a HTML IDE.

    For proper result, yes you do need a webserver, this then ensures any links, files you allow for download, testing of uploads will mean that your code will have everything ready to go and upload to a web server.

    Finally, all web forums have TAGS that allow you to "Wrap" code segments so they are easier to read, please use them.
    I used note pad as an editor.Really i need a web server for displaying the above code in the browser?
    Sorry i have no idea which tags are you talking about for wrapping the code segments?

  5. #5
    Join Date
    Oct 2013
    Posts
    421
    Quote Originally Posted by ITPRO View Post
    I used note pad as an editor.Really i need a web server for displaying the above code in the browser?
    Sorry i have no idea which tags are you talking about for wrapping the code segments?
    No, you don't really need a server to display your posted code. Open your code in notepad and replace all the curly quotes with straight quotes. The script will work.

    Instructions for wrapping your code in "CODE" tags:
    http://www.webdeveloper.com/forum/mi...do=bbcode#code

  6. #6
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    15
    Quote Originally Posted by Kevin2 View Post
    No, you don't really need a server to display your posted code. Open your code in notepad and replace all the curly quotes with straight quotes. The script will work.

    Instructions for wrapping your code in "CODE" tags:
    http://www.webdeveloper.com/forum/mi...do=bbcode#code
    Thank you very much.I just replaced curly quotes with the straight quote and it,s working.Can you please explain why curly quotes don,t work with a java script ?

  7. #7
    Join Date
    Oct 2013
    Posts
    421
    Quote Originally Posted by ITPRO View Post
    Thank you very much.I just replaced curly quotes with the straight quote and it,s working.Can you please explain why curly quotes don,t work with a java script ?
    Because HTML and Javascript are plain text. Curly quotes are not. They mean nothing to either coding language, as well as any other that relies on the code being plain text. Curly quotes are for humans, straight quotes are for computers and servers.

    Kind of like how commas (,) are not apostrophes (') [don,t != don't], and most people put a space between a period and the beginning of a new sentence ...
    Last edited by Kevin2; 01-21-2014 at 02:31 PM.

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,223
    The TAGS are [ code ]...[ /code ] and [ php ]...[ /php ] and [ html ]...[ /html ] only code is uppercase CODE, php is PHP and you got it... html is HTML and the ellipses (thats these things ... ) represent the area you put your code in and you have no spaces in the []'s

    Development servers come in various flavors, from EasyPHP to XAMPP (which is popular), try googling it.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  9. #9
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,223
    "Curly" quotes are "back ticks"

    The issues of testing depend on what your page is doing, fine, test without a web server but as soon as you need to use AJAX, your stuffed, so you are best off using a development environment and get used to using a webserver for serving up pages for testing and you then begin to appreciate how PHP, HTML and JavaScript all can work together as well as other items like MySQL and SQLite.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  10. #10
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    15
    Quote Originally Posted by \\.\ View Post
    "Curly" quotes are "back ticks"

    The issues of testing depend on what your page is doing, fine, test without a web server but as soon as you need to use AJAX, your stuffed, so you are best off using a development environment and get used to using a webserver for serving up pages for testing and you then begin to appreciate how PHP, HTML and JavaScript all can work together as well as other items like MySQL and SQLite.
    Again my client site development have nothing to do with a local server environment.Btw i already had XAMPP installed on my laptop.

  11. #11
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,223
    Quote Originally Posted by ITPRO View Post
    Again my client site development have nothing to do with a local server environment.
    I don't think you are understanding the issue. If you develop any kind of code, you have limited capability without a server. When you start delving in to the realms of AJAX and other client side elements, you need a web server, any HTML forms you make which rely on uploading also need to be served from a server.

    Your development server can be on any PC you like, the one you work on is something you can also test on prior to upload to your productions server, that is how people developing web services will work, the bigger kids have the full train set.

    in its simplest form, whilst you are able to test some javascript in your browser without a server, look at it in this light...

    Testing with no server == bad.
    Testing with development server == good.
    Quote Originally Posted by ITPRO View Post
    Btw i already had XAMPP installed on my laptop.
    Then use it.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  12. #12
    Join Date
    Oct 2013
    Posts
    421
    I'm still trying to figure out how downloading, setting up, learning, etc. an entire server package solves a problem with curly (AKA "Smart") quotes, or as you call them "back ticks".

    Seriously, that's your solution to a problem with a 12 line script that has issues with quote marks? Was the question about AJAX, MySQL, SQLite, or PHP? I didn't see that in the post. I saw a question about JavaScript and HTML.

    But perhaps I misunderstood the original question...

  13. #13
    Join Date
    Jan 2014
    Location
    Pakistan
    Posts
    15
    Quote Originally Posted by Kevin2 View Post
    I'm still trying to figure out how downloading, setting up, learning, etc. an entire server package solves a problem with curly (AKA "Smart") quotes, or as you call them "back ticks".

    Seriously, that's your solution to a problem with a 12 line script that has issues with quote marks? Was the question about AJAX, MySQL, SQLite, or PHP? I didn't see that in the post. I saw a question about JavaScript and HTML.

    But perhaps I misunderstood the original question...
    Yea that,s what i was also thinking about.You identified the problem well and solved it in no time )

  14. #14
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,223
    Quote Originally Posted by Kevin2 View Post
    I'm still trying to figure out how downloading, setting up, learning, etc. an entire server package solves a problem with curly (AKA "Smart") quotes, or as you call them "back ticks".

    Seriously, that's your solution to a problem with a 12 line script that has issues with quote marks? Was the question about AJAX, MySQL, SQLite, or PHP? I didn't see that in the post. I saw a question about JavaScript and HTML.

    But perhaps I misunderstood the original question...

    As for the setting up and learning aspect of a web server, you don't need to learn, you install a development package that is ready to go and use on you USB stick drive / flash media / hard disk or wherever you fancy trying to stick it. It is not much of a learnig curve and it benefits all concerned.

    I am replying with the "testing" side of things if you must know, the benefit of having a webserver deliver the page and the browser use of its console logs for errors are a great benefit to web development, now if we are finished we can move on.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles