www.webdeveloper.com
Results 1 to 5 of 5

Thread: Getting current time...

  1. #1
    Join Date
    May 2012
    Posts
    3

    Getting current time...

    Hi,
    I am trying to add current time to the svg file I have using Ecmascript.
    following is the code I have. Unfortunately its not working . can someone help me fix it?
    Thank you

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300">
    <text x="0" y="15" fill="red">It is now
    <script type="text/javascript">
    <![CDATA[
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();
    document.write(month + "/" + day + "/" + year);
    ]]>
    </script>
    </text>
    </svg>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415
    What, specifically, seems to be the problem?
    Works in FF browser on iMac.

  3. #3
    Join Date
    May 2012
    Posts
    3
    Quote Originally Posted by JMRKER View Post
    What, specifically, seems to be the problem?
    Works in FF browser on iMac.
    I tried it in Opera browser and it shows nothing (its blank).
    do you have any idea why its happening?

  4. #4
    Join Date
    May 2012
    Posts
    3
    Quote Originally Posted by JMRKER View Post
    What, specifically, seems to be the problem?
    Works in FF browser on iMac.
    I just checked it in firefox:
    all it gives is :
    It is now :

    it does not print the current time.

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415

    Arrow

    I don't know anything about <svg...>
    but this seems to work in my testing of different browsers...
    Code:
    <!DOCTYPE html>
    <head>
    <title>Date info</title>
    </head>
    <body>
    <div style="color:red;position:absolute;top:50px;left:100px;width:150px;border:1px solid blue">
    It is now:
     <span id="currentDateInfo" style="color:black"></span>
    </div>
    
    <script type="text/javascript">
    //<![CDATA[
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();
    document.getElementById('currentDateInfo').innerHTML = month + "/" + day + "/" + year;
    //]]>
    </script>
    </body>
    </html>
    I guess you could check the svg for syntax problems (like the CDATA statement changes)
    Do you have an error console to look at?

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