HighDots Forums  

newbie: problem with calling or including .js file

Javascript JavaScript language (comp.lang.javascript)


Discuss newbie: problem with calling or including .js file in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve
 
Posts: n/a

Default Re: newbie: problem with calling or including .js file - 06-13-2008 , 02:39 AM






On Jun 13, 11:09 am, r_ahims... (AT) poczta (DOT) onet.pl wrote:
Quote:
Hello,
I am learning WWW technologies in Linux. I created index.html file which I
can browse with Firefox/Konqueror using URL
localhost/~robert/rozgloszenia/index.html. The page looks fine but there's
one strange problem: I have written some JavaScript code in functions.js
file which seems to be ignored when called although I have JavaScript
enabled in Firefox/Konqueror.

For example in functions.js I have:

function getCurrentYear()
{
var today = Date();
return today.getFullYear();

}

I have written:

head
...
script src="functions.js" language="javascript"
type="text/javascript"></script
/head

and then I have:

script language="javascript"
type="text/javascript">document.write(getCurrentDate());</script

There's nothing in oputput.

When I have written simple line:

script language="javascript"
type="text/javascript">document.write('ABC');</script

output is correct (ABC characters).
But when I put document.write('ABC'); in Test() function in functions.js and
call it:

script language="javascript" type="text/javascript">Test();</script

then there's nothing in output.

The file functions.js has -rw-rw-r-- priviledges.

Please help.
Thanks in advance.
/RAM/
Hi,

I am also a Linux user and have found out that most users of this
newsgroup are not. The people here are usually very helpful but you
need to first identify whether you have a Linux problem, for instance
a permissions problem, or a HTML/Javascript problem.

The easiest way to do this would be to post your index.html and
functions.js files on a server where the newsgroup users can access
them with their own browsers. If the problem is a Javasript (or HTML)
problem they will help you.

Regards,

Steve.


Reply With Quote
  #2  
Old   
r_ahimsa_m@poczta.onet.pl
 
Posts: n/a

Default newbie: problem with calling or including .js file - 06-13-2008 , 04:09 AM






Hello,
I am learning WWW technologies in Linux. I created index.html file which I
can browse with Firefox/Konqueror using URL
localhost/~robert/rozgloszenia/index.html. The page looks fine but there's
one strange problem: I have written some JavaScript code in functions.js
file which seems to be ignored when called although I have JavaScript
enabled in Firefox/Konqueror.

For example in functions.js I have:

function getCurrentYear()
{
var today = Date();
return today.getFullYear();
}

I have written:

<head>
...
<script src="functions.js" language="javascript"
type="text/javascript"></script>
</head>

and then I have:

<script language="javascript"
type="text/javascript">document.write(getCurrentDate());</script>

There's nothing in oputput.

When I have written simple line:

<script language="javascript"
type="text/javascript">document.write('ABC');</script>

output is correct (ABC characters).
But when I put document.write('ABC'); in Test() function in functions.js and
call it:

<script language="javascript" type="text/javascript">Test();</script>

then there's nothing in output.

The file functions.js has -rw-rw-r-- priviledges.

Please help.
Thanks in advance.
/RAM/

Reply With Quote
  #3  
Old   
SAM
 
Posts: n/a

Default Re: newbie: problem with calling or including .js file - 06-13-2008 , 06:14 AM



r_ahimsa_m (AT) poczta (DOT) onet.pl a écrit :
Quote:
Hello,
I am learning WWW technologies in Linux. I created index.html file which I
can browse with Firefox/Konqueror using URL
localhost/~robert/getCurrentYear/index.html. The page looks fine but there's
one strange problem: I have written some JavaScript code in functions.js
file which seems to be ignored when called although I have JavaScript
enabled in Firefox/Konqueror.
and calling the file by :
file://localhost/Users/robert/getCurrentYear/index.html
or something like that
(to see if it's really a pb of privileges)

Quote:
For example in functions.js I have:

function getCurrentYear()
{
var today = Date();
return today.getFullYear();
}

I have written:

head
...
script src="functions.js" language="javascript"
type="text/javascript"></script
/head

and then I have:

script language="javascript"
type="text/javascript">document.write(getCurrentDate());</script
could be better with : document.write(getCurrentYear());
no ?

--
sm


Reply With Quote
  #4  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: newbie: problem with calling or including .js file - 06-13-2008 , 06:15 AM



r_ahimsa_m (AT) poczta (DOT) onet.pl escribió:
Quote:
localhost/~robert/rozgloszenia/index.html. The page looks fine but there's
one strange problem: I have written some JavaScript code in functions.js
file which seems to be ignored when called although I have JavaScript
enabled in Firefox/Konqueror.
Debugging steps you can take:

1. Check your web server's logs: is the *.js file actually requested? Is
it served successfully?

2. Check Firefox's JavaScript console (Tools menu)

3. Get the Firebug extension for Firefox.

Quote:
script src="functions.js" language="javascript"
type="text/javascript"></script
BTW, the language attribute is deprecated. I suppose you don't validate
your HTML with W3C validator: you should. Extensions like Web Developer
Toolbar for Firefox can help you to validate local HTML or you can just
paste or upload the file:

http://validator.w3.org/


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--


Reply With Quote
  #5  
Old   
Tom Cole
 
Posts: n/a

Default Re: newbie: problem with calling or including .js file - 06-13-2008 , 06:33 AM



On Jun 13, 7:15*am, "Álvaro G. Vicario"
<alvaroNOSPAMTHA... (AT) demogracia (DOT) com> wrote:
Quote:
r_ahims... (AT) poczta (DOT) onet.pl escribió:

localhost/~robert/rozgloszenia/index.html. The page looks fine but there's
one strange problem: I have written some JavaScript code in functions.js
file which seems to be ignored when called although I have JavaScript
enabled in Firefox/Konqueror.

Debugging steps you can take:

1. Check your web server's logs: is the *.js file actually requested? Is
it served successfully?

2. Check Firefox's JavaScript console (Tools menu)

3. Get the Firebug extension for Firefox.

* * * * <script src="functions.js" language="javascript"
type="text/javascript"></script

BTW, the language attribute is deprecated. I suppose you don't validate
your HTML with W3C validator: you should. Extensions like Web Developer
Toolbar for Firefox can help you to validate local HTML or you can just
paste or upload the file:

http://validator.w3.org/

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
I also notice that your function defined in the .js file is named
getCurrentYear, yet the one you're attempting to call is
getCurrentDate...

Do you have Firebug or Venkeman installed on your Firefox
installation? It would show if there were any javascript errors.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.