cdloves
asked on
Moving javascript codes to external file
I am trying to use this script
http://www.dynamicdrive.com/dynamicindex2/crosstick.htm
However, the script is too long and I want to move it to external file. I tried to save the file as "name.js"
then use the following line in body to call it:
===========
SCRIPT LANGUAGE="JavaScript1.2" SRC="name.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
></SCRIPT>
==========
The script works while in the body tag but wouldn't work when I try to move it to external page. Is it possible to move it out at all? (dynamicdrive, the creator is okay with user moving the file to external file)
http://www.dynamicdrive.com/dynamicindex2/crosstick.htm
However, the script is too long and I want to move it to external file. I tried to save the file as "name.js"
then use the following line in body to call it:
===========
SCRIPT LANGUAGE="JavaScript1.2" SRC="name.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
></SCRIPT>
==========
The script works while in the body tag but wouldn't work when I try to move it to external page. Is it possible to move it out at all? (dynamicdrive, the creator is okay with user moving the file to external file)
is your name.js file located in the same folder?
ASKER
YZlat,
Nope that doesn't work either. The javacode works when it's in the actual page, but not when in external file. The file path is right, it is in same folder.
(points increased to 500)
Nope that doesn't work either. The javacode works when it's in the actual page, but not when in external file. The file path is right, it is in same folder.
(points increased to 500)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Getting closer, Timbo87.
The msg is now displayed but it doesn't display at the right location. Its supposed to display in in cell 2,3 of the table, but instead, it's displayed outside the table box.
Anyway to fix this? Thanks
The msg is now displayed but it doesn't display at the right location. Its supposed to display in in cell 2,3 of the table, but instead, it's displayed outside the table box.
Anyway to fix this? Thanks
Place this code:
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor} ; background=&{scrollerbackg round}; visibility=hide>
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0] )
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy ndetermine =(messages .length==1 )? 0 : 1])
</script>
</layer>
</ilayer>
in the <TD> of the desired cell.
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0]
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy
</script>
</layer>
</ilayer>
in the <TD> of the desired cell.
Make sure you still have:
<SCRIPT LANGUAGE="JavaScript1.2" SRC="name.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
></SCRIPT>
In the <HEAD>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="name.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
></SCRIPT>
In the <HEAD>
ASKER
<HTML>
<HEAD><TITLE>Your Company Name</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="script.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
</SCRIPT>
</HEAD>
<BODY>
<TABLE BORDER = 1 ALIGN="center" WIDTH="750">
<TR><TD COLSPAN="3"></TD></TR>
<TR bgcolor="black"><TD COLSPAN="3"> </TD></T R>
<TR>
<TD Name="left" VALIGN="top" WIDTH="120px" background="" COLSPAN="1">S<BR><BR><BR>< BR><BR><BR ><BR><BR>< BR><BR><BR ><BR>S</TD >
<TD Name="body" VALIGN="top" WIDTH="430px"></TD>
<TD Name="right" VALIGN="top" Width="200px">___
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor} ; background=&{scrollerbackg round}; visibility=hide>
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0] )
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy ndetermine =(messages .length==1 )? 0 : 1])
</script>
</layer>
</ilayer>
</TR>
<TR bgcolor="black"><TD COLSPAN=3 ALIGN="center"> <FONT COLOR="white"></FONT></TD> </TR>
</TABLE>
<BODY>
</HTML>
<HEAD><TITLE>Your Company Name</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="script.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
</SCRIPT>
</HEAD>
<BODY>
<TABLE BORDER = 1 ALIGN="center" WIDTH="750">
<TR><TD COLSPAN="3"></TD></TR>
<TR bgcolor="black"><TD COLSPAN="3"> </TD></T
<TR>
<TD Name="left" VALIGN="top" WIDTH="120px" background="" COLSPAN="1">S<BR><BR><BR><
<TD Name="body" VALIGN="top" WIDTH="430px"></TD>
<TD Name="right" VALIGN="top" Width="200px">___
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0]
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy
</script>
</layer>
</ilayer>
</TR>
<TR bgcolor="black"><TD COLSPAN=3 ALIGN="center"> <FONT COLOR="white"></FONT></TD>
</TABLE>
<BODY>
</HTML>
ASKER
above is my page info, but the msg is not in the <TD> where it belongs to. the JS file is called "script.js"
Hmm, I was wrong. It looks like you just need the <SCRIPT> tag.
<HTML>
<HEAD><TITLE>Your Company Name</TITLE>
</HEAD>
<BODY>
<TABLE BORDER = 1 ALIGN="center" WIDTH="750">
<TR><TD COLSPAN="3"></TD></TR>
<TR bgcolor="black"><TD COLSPAN="3"> </TD></T R>
<TR>
<TD Name="left" VALIGN="top" WIDTH="120px" background="" COLSPAN="1">S<BR><BR><BR>< BR><BR><BR ><BR><BR>< BR><BR><BR ><BR>S</TD >
<TD Name="body" VALIGN="top" WIDTH="430px"></TD>
<TD Name="right" VALIGN="top" Width="200px">___
<SCRIPT LANGUAGE="JavaScript1.2" SRC="script.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
</SCRIPT>
</TD>
</TR>
<TR bgcolor="black"><TD COLSPAN=3 ALIGN="center"> <FONT COLOR="white"></FONT></TD> </TR>
</TABLE>
<BODY>
</HTML>
<HTML>
<HEAD><TITLE>Your Company Name</TITLE>
</HEAD>
<BODY>
<TABLE BORDER = 1 ALIGN="center" WIDTH="750">
<TR><TD COLSPAN="3"></TD></TR>
<TR bgcolor="black"><TD COLSPAN="3"> </TD></T
<TR>
<TD Name="left" VALIGN="top" WIDTH="120px" background="" COLSPAN="1">S<BR><BR><BR><
<TD Name="body" VALIGN="top" WIDTH="430px"></TD>
<TD Name="right" VALIGN="top" Width="200px">___
<SCRIPT LANGUAGE="JavaScript1.2" SRC="script.js" TYPE='text/javascript'>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
</SCRIPT>
</TD>
</TR>
<TR bgcolor="black"><TD COLSPAN=3 ALIGN="center"> <FONT COLOR="white"></FONT></TD>
</TABLE>
<BODY>
</HTML>
ASKER
It still didn't move the msg window to the right location though...
ASKER
Finally got it to work, I have to remove the <SCRIPT> tag in the head section.
Yes, I have removed that in the complete version posted above.
ASKER
Thanks for the help all.
ASKER
Oh, I didn't notice that. I thought the <div>, etc. tags were the only ones you removed.
Thanks again for the help.
Thanks again for the help.
ASKER
Tim,
Are you still reading this by any chance? I need your helping still.
Are you still reading this by any chance? I need your helping still.
Yes?
ASKER
I just tested the modified code and it doesn't work for Netscape 6. Only the first two links are showed, then it stops completely. Do you think you could help me fix it? I'll make a new question and award you another 500 points once done.
Thanks in advance.
Thanks in advance.
Add this to the <TD>
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor} ; background=&{scrollerbackg round}; visibility=hide>
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0] )
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy ndetermine =(messages .length==1 )? 0 : 1])
</script>
</layer>
</ilayer>
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0]
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dy
</script>
</layer>
</ilayer>
<script LANGUAGE="JavaScript1.2" SRC="name.js" TYPE="text/javascript"></s
that's all. If it does not work, then the error must be either in the file path or the file itself