Not displaying in browser?

Probably has a simple answer.

Page 1 of 1

9 Replies - 615 Views - Last Post: 25 November 2009 - 09:18 AM

#1 Barnz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 28-December 08

Not displaying in browser?

Post icon  Posted 22 November 2009 - 03:09 PM

I have no idea why, but the following code does not display anything in any of the major browsers.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Test Site</title>
	<link href="main.css" rel="stylesheet" type="text/css" />
  </head>
	<body>
	<h1>
	 This is but a humble test :]
	</h1>
	<div id="tad">
	  <script type="text/javascript">
		var d = new Date();
		var hrs = d.getHours();
		var mins = d.getMinutes();
		var day = d.getDay()
		var month = d.getMonth();
		var year = d.getFullYear();
		
		if (d.getMinutes>10)
		{
			document.write("<p>" + day + "/" + month + "/" + year + "<p />" + hrs + ":" + "0" + mins + " :]" + "</p>")
		}
		else

		document.write("<p>" + day + "/" + month + "/" + year + "<p />" + hrs + ":" + mins + " :]" + "</p>")

	  </script>
	  <br />
	  <img src="images/line.png" width="240px" height="10px;"/> 
	  <br />
	</div>
	<br />
	<div class="menu">
	  <ul>
		<li><a href="#">Home</a></li>
		<li><a href="#">Contact</a></li>
		<li><a href="#">About</a></li>
		<li><a href="url">Links</a></li>
		<li><a href="url">Forum</a></li>
	  </ul>
	</div>
	<h2>
	  Hallelujah! 
	</h2>
	<div id="rightbar">
	  <p>
		Etiam at massa nec erat sodales placerat. Aliquam erat volutpat. Donec vitae eros magna. Etiam suscipit magna quis mauris tempor ac eleifend justo viverra. Pellentesque habitant morbi tristique senectus et netus et 
	  </p>
	</div>
	<div id="post">
	  <p>
		Lorem inunc.<br /> 
er. Maecenas pharetra scelerisque velit, feugiat euismod metus aliquam vitae. In ut neque felis. Mauris ut pulvinar aus erat. Nullam ut nisl nisl. Quisque consequat imperdiet tempus. Nulla congue orci convallis turpis dictum fringilla. <br />
	  </p>
	</div>
	<div id="footer">
	  <p>
		Copyright &copy; 2009 Barnaby Turner | In association with <a href="http://www.aesardesigns.co.uk/">Aesar Designs</a>.
	  </p>
	</div>
  </body>
</html>


Javascript newb here :)

Is This A Good Question/Topic? 0
  • +

Replies To: Not displaying in browser?

#2 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 124
  • View blog
  • Posts: 701
  • Joined: 28-April 07

Re: Not displaying in browser?

Posted 22 November 2009 - 11:53 PM

hi,
it displays the date and time, what else do you expected?.

notes:
instead of
if (d.getMinutes>10)
        {
            document.write("<p>" + day + "/" + month + "/" + year + "<p />" + hrs + ":" + "0" + mins + " :]" + "</p>")
        }
        else

        document.write("<p>" + day + "/" + month + "/" + year + "<p />" + hrs + ":" + mins + " :]" + "</p>")


you can do:
document.write("<p>" + day + "/" + month + "/" + year + "<p />" + hrs + ":" +((mins<10)?"0":"") + mins + " :]" + "</p>")



and i don't know if you're trying to add line break using ( "<p />")
if it so, it should be ("<br />")

hope it helps
Was This Post Helpful? 0
  • +
  • -

#3 Barnz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 28-December 08

Re: Not displaying in browser?

Posted 23 November 2009 - 03:40 PM

Thanks for your reply. I know what it does man, it's just when I upload the page to my server, and point my browser at the document, the xhtml is displayed, but no Javascript output. It works perfectly in Dreamweaver CS4 live view. I'm just not sure whats going on.
Was This Post Helpful? 0
  • +
  • -

#4 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 124
  • View blog
  • Posts: 701
  • Joined: 28-April 07

Re: Not displaying in browser?

Posted 23 November 2009 - 11:20 PM

well, I tested it on IE 8, FF 3.5 and Chrome 4 and it worked with no problems.

so, did you try to run it locally without Dreamweaver?
or, can you provide us a link to your website so we can test it.
Was This Post Helpful? 0
  • +
  • -

#5 sl4ck3r  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 285
  • Joined: 22-September 07

Re: Not displaying in browser?

Posted 23 November 2009 - 11:31 PM

did you save it as a .html file? not .txt or any other extension. probably something simple like that.
Was This Post Helpful? 0
  • +
  • -

#6 Barnz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 28-December 08

Re: Not displaying in browser?

Posted 24 November 2009 - 10:59 AM

Here is the link to the file. The extension is .xhtml - could that be the problem?

And no - it doesn't work locally either.

Thanks,

This post has been edited by Barnz: 24 November 2009 - 11:03 AM

Was This Post Helpful? 0
  • +
  • -

#7 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1619
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Not displaying in browser?

Posted 24 November 2009 - 11:03 AM

Change the extension to either .html or .htm. That should change it for you
Was This Post Helpful? 1
  • +
  • -

#8 Barnz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 28-December 08

Re: Not displaying in browser?

Posted 24 November 2009 - 11:13 AM

Worked perfectly. Thank you, I feel kind of stupid now - haha. Just wondering why that would make a difference, does xhtml not support Javascript?
Was This Post Helpful? 0
  • +
  • -

#9 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 124
  • View blog
  • Posts: 701
  • Joined: 28-April 07

Re: Not displaying in browser?

Posted 25 November 2009 - 02:43 AM

Yes, it's the XHTML thing,

simply, put your code inside CDATA tag
<script type="text/javascript" >
//<![CDATA[
your code here
//]]>



or put the code in external .js file

ref: http://www.codehouse...ipt/tips/xhtml/

it helps me, i hope it helps you too :)
Was This Post Helpful? 0
  • +
  • -

#10 Barnz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 28-December 08

Re: Not displaying in browser?

Posted 25 November 2009 - 09:18 AM

Works perfectly! Thank you for your help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1