Forum Moderators: open

Message Too Old, No Replies

In need of a last updated script that works with XHTML?

Having problems to also make it work in firefox and ie,any solutions?

         

Splendor

3:02 am on Feb 14, 2005 (gmt 0)

10+ Year Member



Hi ppl!:)

I'm wondering about a javascript. i don't know anything about it.Thats why i'm trying to get some help from u guys=))
i'm trying to implement a last update script into xhtml,saved as external file.The problems is i can't make it work:P..need some how to?

And anyone with tips about a "last updated" javascript that works with xhtml and can be shown with no problems at all in these two browsers such as Firefox and Ie? T

Tnx
Greetings
Splendor

orion_rus

9:10 am on Feb 14, 2005 (gmt 0)

10+ Year Member



May be you can tell us some more information?
I think you use XML and then with XSLT transfer it to XHTML in a server side... but javascript is a client side language, it works great with any xhtml version. And what script do you need? where are a lot of it already written in a javascript..

Bernard Marx

9:47 am on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using document.write?

You could replace it like this:


<span id="flastmod"></span>
<script>
document.getElementById('flastmod')
.appendChild(document.createTextNode(document.lastModified));
</script>

Splendor

3:07 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Hi again!

i'm using this javascript:

<!-- hide script begin
var m = "Last Updated " + document.lastModified;
var p = m.length-8;
document.writeln("<center>");
document.write(m.substring(p, 0));
document.writeln("</center>");
// End -->

does work on ie but not in firefox...why?

Bernard Marx

3:43 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.write is illegal is strict XHTML.
er..I think it's because it could allow invalid content to be inserted
- same goes for innerHTML

[autisticcuckoo.net...]

(amongst others)

Splendor

4:19 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



aha..i wasn't aware of this.i'm using the strict dtd of xhtml and it's all w3c valid. So do u think it's a way to make this script work without the dokument write?..

Greetings Splendor

encyclo

4:26 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Splendor, the only time you should have a problem with document.write and XHTML is if you are doing mime-type switching and serving the page as
application/xhtml+xml
to Mozilla/Firefox. If you don't know what I'm talking about, then you aren't doing it! ;)

If you are talking about an XHTML page served as standard HTML, then your problem lies elsewhere.

Splendor

4:48 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



This is only the test:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!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" xml:lang="sv" lang="sv">

<head>

<title>TEST</title>
<link rel="stylesheet" type="text/css" href="mod.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

<body>

<script type="text/javascript">
<!-- hide script begin
var m = "Last Updated " + document.lastModified;
var p = m.length-8;
document.writeln("<center>");
document.write(m.substring(p, 0));
document.writeln("</center>");
// End -->
</script>

</body>

</html>

encyclo

5:09 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Splendor, your test document works fine in Firefox 1.0 here. I'm not sure why you want to chop off the last 8 characters (which makes half the time disappear), but the script is doing exactly what you are asking of it.

Splendor

5:30 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



very intresting because my firefox doesn't show anything,only the title..not the last updated script..hmm!?!?

encyclo

5:47 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you viewing this file locally or via a webserver? What file extension does it have?

When on your page, press Control+I to get the page info dialog. Look for "Type". Does it list the type as

text/html
? Also go to the Javascript console to see if you have any errors.

Splendor

6:17 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



yes locally and using *.xhtml...

encyclo

6:26 pm on Feb 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes locally and using *.xhtml...

Your document is probably being parsed as

application/xhtml+xml
- which you don't want. Try renaming the file *.html and test again - it should work as expected.

Splendor

6:53 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



yeeees!it works:P:P:P..thank u very much =))

tnx
Splendor