p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning HTML, XHTML, CSS, and JavaScript (http://p2p.wrox.com/forumdisplay.php?f=541)
-   -   JavaScript (http://p2p.wrox.com/showthread.php?t=83166)

crashbandicoot April 4th, 2011 07:54 AM

JavaScript
 
Does anyone know whats wrong with this code? The screen is blank, even though I enable and allow scripts and Active X conrols to be on. I've even tried putting the javascipt code in the body element instead of the head, but still nothing happens? any clues?

<?xml version="1.0" ?>
<!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" lang="en">
<head>
<title>Getting the date</title>



<script type="text/JavaScript">

date = new Date();
time = date.getHours();

if (time < 12) {
document.write("Good Morning");
}
if (time < 18 && time => 12) {
document.write("Good Afternoon");
}
if (time => 18 && time < 24) {
document.write("Good Evening");
}
</script>
</head>

</html>

Thanks

disel2010 April 4th, 2011 09:24 AM

Hi,

I guess it's a probem with the order of the equal / greater than signs.

This works for me (equal sign behind the greater than sign):

Code:

<script type="text/JavaScript">

date = new Date();
time = date.getHours();

if (time < 12) {
document.write("Good Morning");
}
if (time < 18 && time >= 12) {
document.write("Good Afternoon");
}
if (time >= 18 && time < 24) {
document.write("Good Evening");
}
</script>


unicode April 27th, 2011 06:14 AM

static, dynamic and properties window in javascript
 
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<SCRIPT>
function properties_page()
{
for (var i in window)
{
document.write (“Window property(” + i + “): ” +
window[i] + “<BR>”);
}
}
</SCRIPT>
<script language=”JavaScript”>
function dynamic_page(){
open(“http://www.java2s.com”, “myChild”);
}
function static_page()
{
window.open(“http://www.w3schools.com/PHP/php_arrays.asp”, “newWin”,
“resizeable,menubar,toolbar”);
}
</script>
<form name=”form1″>
<input type=”button” name=”b1″ value=”dynamic Child” onClick=’dynamic_page()’>
<input type=”button” name=”b2″ value=”static resize” onClick=’static_page()’>
<input type=”button” name=”b3″ value=”properties_page” onClick=’properties_page()’>
</form>
</body>
</html>
unicodesystems


All times are GMT -4. The time now is 02:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.