javascript dies on IIS server

C

Cloy

The script below loads a calendar page in an iframe and scrolls to
today's date.

It works just dandy on my apache/linux server, but won't do anything
when I use IIS. (Nothing appears on the page at all where the script is
at.)

I'd appreciate any suggestions on how to make this work from the IIS
server.

Thanks, in advance!

-Cloy


<script language="JavaScript" type="text/JavaScript">
<!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

document.write
("<iframe name=\"Calendar\" width=\"215\" marginwidth=\"0\"
height=\"500\"
marginheight=\"0\" align=\"top\" scrolling=\"auto\" hspace=\"0\"
vspace=\"0\"
src=\"calendar.htm#" +
month + day + year
+ "\"");
//-->
</script>
 
A

agapeton

Errrrrrrr... first off language="JavaScript" needs to go. That's not
even JavaScript anymore...

Secondly, document.write dies MANY years ago. I would highly suggest
you learn DOM programming.

Third, check the content type IIS is sending the thing as. It may be
sending it as something stupid.
 
R

Randy Webb

(e-mail address removed) said the following on 9/28/2006 11:00 PM:
Errrrrrrr... first off language="JavaScript" needs to go. That's not
even JavaScript anymore...

It never was Javascript to start with. It is an HTML attribute.
Secondly, document.write dies MANY years ago. I would highly suggest
you learn DOM programming.

That's idiotic. Sure, there are other ways to do it, but sometimes
document.write is just the simplest way.
Third, check the content type IIS is sending the thing as. It may be
sending it as something stupid.

And you think IE pays attention to content type? It tries to render
anything and everything.

Fourth, and most importantly, make sure you don't have a path/filename
collision.

Fifth, ignore idiotic top-posters.
 
R

RobG

Errrrrrrr... first off language="JavaScript" needs to go. That's not
even JavaScript anymore...

Please don't top-post, reply below trimmed quotes.

The language attribute never was part of JavaScript, it was introduced
as a deprecated attribute in HTML 4.

Secondly, document.write dies MANY years ago.

I doubt that you can find a visual UA with script support that doesn't
support it.

I would highly suggest you learn DOM programming.

Considering document.write() is a method of the document object, it
*is* "DOM programming".

Third, check the content type IIS is sending the thing as. It may be
sending it as something stupid.

I suppose you are referring to the possibility that the document is
being served as XHTML. In that case, document.write won't work - but
there is nothing to indicate that is the case.


Do not use HTML comments inside script elements, they are unnecessary.


Better to use getFullYear() unless very old browser support is
required. Have you considered an "add leading zero" function?

function addZ(num){ return (num<10)? '0'+num : num;}


That seems an inappropriate choice of date format, why not use an ISO
format? Say yyyymmdd? Using addZ(), you can generate the date string
as:

var d = new Date();

document.write(
'<iframe ...
+ ' src="calendar.htm#' + d.getFullYear()
+ addZ(d.getMonth()+1) + addZ(d.getDate()+1)"'
);

You don't seem to have properly closed the element, where is the
 
K

Ken Schaefer

Hi,

Please look in the browser's source view, to see if the javascript has made
it to the client. If it has, then this has nothing to do with IIS. IIS just
sends the HTML, CSS, javascript etc to the client. It is up to the client to
parse/intepret the HTML, CSS, javascript etc

Cheers
Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top