ag******@gmail.com wrote:
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.
Cloy wrote:
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">
<!--
Do not use HTML comments inside script elements, they are unnecessary.
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;
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;}
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
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
'></iframe>' string?
//-->
</script>
--
Rob