473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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.

--
Andy
"A little pain never hurt anyone!" Sam, aged 11
Jul 23 '05 #1
3 1136
Andy Stevenson wrote:
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
Jul 23 '05 #2
JRS: In article <pA*************@newsfe3-gui.ntli.net>, dated Wed, 28
Jul 2004 01:47:01, seen in news:comp.lang.javascript, Andy Stevenson
<no@chance.com> posted :
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>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #3
[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.
--
Andy
"A little pain never hurt anyone!" Sam, aged 11
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
5
by: Yves-Alain NICOLLET | last post by:
How is it that when I include a script within a document it works and when I try to get it from my webserver it does not seem to work at all? I have documents on my webserver that contain a...
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
2
by: Mariame | last post by:
Hi Everyone How to embeded a Flash file ".swf" in aspx page??? Thx in Advance
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
2
by: Sunny | last post by:
Hi, I have an application using IE6 before and now we have upgraded to IE7. After upgrading, I have been having issues with button click event when embedded JavaScript file into the page....
20
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it?...
0
by: Pitaridis Aristotelis | last post by:
I know how to extract an embeded resource from a file but does anyone how to import an embeded resource to a file?
0
by: raycini | last post by:
Hi I used to play a wav file from a specified location on hard drive using the following code:- public void Play(int pitch) { myPlayer.SoundLocation = "g:\\mapped\\" +...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.