|
 |
beginning_javascript thread: External JavaScript
Message #1 by "Tom Nocer" <chevelleneeded@y...> on Sat, 25 Jan 2003 06:41:54
|
|
When I try to have more than 1 External JavaScript on my page only the 1st
script that is refferenced to is working.
Example: in the <head> I have
<script language="JavaScript" type="text/javascript" src="mouseover.js">
</script>
<script language="JavaScript" type="text/javascript" src="help.js">
</script>
but only 'mouseover' works in the page and not 'help'. Is there anyway
that I can include 2 or more external JS in one page?
Thanks Tom
PS- I have included my code from the external JS:
var MyEvent
function EventOverNN(e)
{
var MySrcElement = e?e.target:window.event.srcElement
if(MySrcElement.tagName == "TR")
{
MyEvent = MySrcElement
}
else if(MySrcElement.parentNode.tagName == "TR")
{
MyEvent = MySrcElement.parentNode
}
if(MyEvent)
{
MyEvent.style.backgroundColor = "#E8E8E8";
MyEvent.style.color = "#000099";
MyAnchors = MyEvent.getElementsByTagName("A");
for(var i=0; i< MyAnchors.length; i++)
{
MyAnchors[i].style.color = "#";
}
}
}
function EventOutNN(e)
{
var MySrcElement = e?e.target:window.event.srcElement
if(MySrcElement.tagName == "TR")
{
MyEvent = MySrcElement
}
else if(MySrcElement.parentNode.tagName == "TR")
{
MyEvent = MySrcElement.parentNode
}
if(MyEvent)
{
MyEvent.style.backgroundColor = "";
MyEvent.style.color = "";
MyAnchors = MyEvent.getElementsByTagName("A");
for(var i=0; i< MyAnchors.length; i++)
{
MyAnchors[i].style.color = "";
}
}
}
function init()
{
document.getElementById("Mouseover").onmouseover = EventOverNN
document.getElementById("Mouseover").onmouseout = EventOutNN
}
Message #2 by <pankaj.shinde@i...> on Sat, 25 Jan 2003 12:24:52 +0530
|
|
Hi Tom,
Make sure that both JS files and calling file lies in same folder.
In a help file add a small function
function test(){
alert("I am in Help File");
}
call this function in ur main file to test whether the file is included
or not.
Don't use same function name in JS files.
I think becoz of some other problem ur program is not able to use the
functions in Help file.
With Regards,
-Pankaj
-----Original Message-----
From: Tom Nocer [mailto:chevelleneeded@y...]
Sent: Saturday, January 25, 2003 12:12 PM
To: Beginning JavaScript
Subject: [beginning_javascript] External JavaScript
When I try to have more than 1 External JavaScript on my page only the
1st
script that is refferenced to is working.
Example: in the <head> I have
<script language=3D"JavaScript" type=3D"text/javascript"
src=3D"mouseover.js">
</script>
<script language=3D"JavaScript" type=3D"text/javascript"
src=3D"help.js">
</script>
but only 'mouseover' works in the page and not 'help'. Is there anyway
that I can include 2 or more external JS in one page?
Thanks Tom
PS- I have included my code from the external JS:
var MyEvent
function EventOverNN(e)
{
var MySrcElement =3D e?e.target:window.event.srcElement
if(MySrcElement.tagName =3D=3D "TR")
{
MyEvent =3D MySrcElement
}
else if(MySrcElement.parentNode.tagName =3D=3D "TR")
{
MyEvent =3D MySrcElement.parentNode
}
if(MyEvent)
{
MyEvent.style.backgroundColor =3D "#E8E8E8";
MyEvent.style.color =3D "#000099";
MyAnchors =3D MyEvent.getElementsByTagName("A");
for(var i=3D0; i< MyAnchors.length; i++)
{
MyAnchors[i].style.color =3D "#";
}
}
}
function EventOutNN(e)
{
var MySrcElement =3D e?e.target:window.event.srcElement
if(MySrcElement.tagName =3D=3D "TR")
{
MyEvent =3D MySrcElement
}
else if(MySrcElement.parentNode.tagName =3D=3D "TR")
{
MyEvent =3D MySrcElement.parentNode
}
if(MyEvent)
{
MyEvent.style.backgroundColor =3D "";
MyEvent.style.color =3D "";
MyAnchors =3D MyEvent.getElementsByTagName("A");
for(var i=3D0; i< MyAnchors.length; i++)
{
MyAnchors[i].style.color =3D "";
}
}
}
function init()
{
document.getElementById("Mouseover").onmouseover =3D EventOverNN
document.getElementById("Mouseover").onmouseout =3D EventOutNN
}
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20
Message #3 by "Tom Nocer" <chevelleneeded@y...> on Sat, 25 Jan 2003 17:48:47
|
|
Both JS files are in the same folder but still only 2nd one listed will
work. What do you think the problem could be???
Tom
Hi Tom,
Make sure that both JS files and calling file lies in same folder.
In a help file add a small function
function test(){
alert("I am in Help File");
}
call this function in ur main file to test whether the file is included
or not.
Don't use same function name in JS files.
I think becoz of some other problem ur program is not able to use the
functions in Help file.
With Regards,
-Pankaj
|
|
 |