Script works when embeded, but not from .js file?

A

Andy Stevenson

Hi,

As subject, I have the following JS in my HTML document & it works fine:

<SCRIPT type="text/JavaScript">
<!--
COPYRIGHT = " : Copyright &copy; Diverse Arts., 2003-";
function writeCopyright()
{
document.write(COPYRIGHT, new Date().getFullYear(), ". All rights
reserved.");
}
var m = "Page updated " + document.lastModified;
var p = m.length-8;
document.write(m.substring(p, 0));
writeCopyright();
// End -->
</SCRIPT>

when I put this in footer.js & call it with <SCRIPT TYPE="text/javascript"
SRC="/js/footer.js"></SCRIPT> I get nothing.

Javascripts not my strong suit, so apologies if I'm missing something
obvious, but anyone got an idea why this won't work?

TIA.
 
T

Thomas 'PointedEars' Lahn

Andy said:
As subject, I have the following JS in my HTML document & it works fine:

<SCRIPT type="text/JavaScript">

You should lowercase tag names, attribute names and MIME types.

Remove that, it is obsolete.
[...]
// End -->

You should remove that, too.
</SCRIPT>

See above.
when I put this in footer.js & call it with <SCRIPT TYPE="text/javascript"
SRC="/js/footer.js"></SCRIPT> I get nothing.

Wrong, you get a script error, but your current environment does not
show it.
Javascripts not my strong suit, so apologies if I'm missing something
obvious, but anyone got an idea why this won't work?

Because HTML is not J(ava)Script. You need to remove any HTML code
from the .js file (unless it is located within string literals).


PointedEars
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Wed, 28
Jul 2004 01:47:01, seen in Andy Stevenson
Hi,

As subject, I have the following JS in my HTML document & it works fine:

<SCRIPT type="text/JavaScript">
<!--
COPYRIGHT = " : Copyright &copy; Diverse Arts., 2003-";
function writeCopyright()
{
document.write(COPYRIGHT, new Date().getFullYear(), ". All rights
reserved.");
}

That should be legally ineffective. Copyright dates from the final
creative act, not from the date of reading the document. If you cannot
update the date once every few years to prove you're alive, you do not
deserve fresh copyright.
var m = "Page updated " + document.lastModified;
var p = m.length-8;
document.write(m.substring(p, 0));

That will, for some combinations of browser and user, display the date
in a potentially-misleading transatlantic form.

At least one browser, I am told, does not put the time at the end of the
string; you will mis-cut.

Generally, it will not be clear whether the date is user's local or GMT.
It cannot be author's local, as such.

An author should be capable of updating the date, in HTML text, when he
changes the page significantly; it should be left unchanged if, for
example, minor non-deceptive typos are corrected.

<URL:http://www.merlyn.demon.co.uk/js-date3.htm#lM>.
 
A

Andy Stevenson

[snip]
That should be legally ineffective. Copyright dates from the final
creative act, not from the date of reading the document. If you
cannot update the date once every few years to prove you're alive,
you do not deserve fresh copyright. [snip]
That will, for some combinations of browser and user, display the date
in a potentially-misleading transatlantic form.

At least one browser, I am told, does not put the time at the end of
the string; you will mis-cut.

Generally, it will not be clear whether the date is user's local or
GMT. It cannot be author's local, as such.

An author should be capable of updating the date, in HTML text, when
he changes the page significantly; it should be left unchanged if, for
example, minor non-deceptive typos are corrected.

<URL:http://www.merlyn.demon.co.uk/js-date3.htm#lM>.

Fair comments, I'm just playing around with lazy ways to do stuff at the
moment. I've not investigated the legallities of copyright yet. We're a long
way from that at the moment :)

Thank you both for the replies, script now working & I've learnt a few
things. Much appriciated.
 

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,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top