PDA

View Full Version : HELP: external .js file - some trick things are happenning


head_0n
07-14-2002, 01:28 PM
hello,

i know it is possible to create some javascript file with scripts available for all my pages - some .js external file. but how can i do that? and how can i call my script from the external file so i can use an onLoad event?
i've used the "gotoURL" behaviour from DW. it gives me a script and the onLoad event.

my "go to URL" script:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}
//-->
</script>


onLoad event:
<body onLoad="MM_goToURL('parent.frames[\'janelab\']','02-homem1.htm');return document.MM_returnValue"></body>

i've already created a .js file and i know the script to call the file, but how to make the onLoad functioning?

call a .js file:
<script language="JavaScript" src="gotoURL.js" type="text/javascript" ></script>

and the .js file contains the up script without "<script></script>" parts but it doesn't function at all!!!!

you may find my project here:
http://membres.lycos.fr/abelp/ciclo

thanks for all your help.

head_0n
07-14-2002, 08:42 PM
ok Dave, so why doesn't my .js file function?!

my gotourl.js file got this script:
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args+".location='"+args[i+1]+"'");
}

and it's called by:
<script language="JavaScript" type="text/JavaScript" SRC="gotourl.js">
</script>

and loaded at the onLoad event, located at <body>.
do you think i should locate it in some other place?
<body onLoad="MM_goToURL('parent.frames['janelab']','02-homem1.htm');return document.MM_returnValue"></body>

i'm sorry if i'm repeating myself, but i'm desperate here :(
please give me some help, there's something i'm not managing quite well.
i've posted the url where you can see the script functioning by being write in the page NOT using an external .js file.
please check what i need to do here (http://membres.lycos.fr/abelp/ciclo)

i'm also attaching my .js file so you can take a look.

thanks once again.
abel.

head_0n
07-14-2002, 11:29 PM
even with that syntax corrected :( :( :(
what's missing there?!...
:( :( :(

head_0n
07-15-2002, 12:44 PM
thanks Dave the script is functioning quite well!!!

suggestion: send it to macromedia ;)

is it possible to explain the diferences bettween your remodeled script and the orignal? i would like to know them if you have time for it.

i was also commiting a second error:
i should place

<script language="JavaScript" type="text/JavaScript" SRC="gotoURL.js"></script>

on every page.
my "02-homem1.htm" (the page that it's called by the onLoad event) wasn't filled with that script, so the .js didn't function outside my local disk (in the server).

i want to thanks all those who helped me too.

:thumbsup: YEAHP, IT'S OK NOW!! :thumbsup:
abel.