Closed Thread Icon

Preserved Topic: External/Internal Scripts (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18129" title="Pages that link to Preserved Topic: External/Internal Scripts (Page 1 of 1)" rel="nofollow" >Preserved Topic: External/Internal Scripts <span class="small">(Page 1 of 1)</span>\

 
Relain
Paranoid (IV) Inmate

From: westernesse
Insane since: Jul 2000

posted posted 08-20-2001 00:06

Calling all javascript gods. simple question, if i have a script with a top tag like:

<script language="javascript" src="script.js">
and then put some code where you would usually put code...
code code code
</script>

what will happen? it'd be cool if it would sort of reference the script file and then do whats in the middle of the tag. any ideas anyone? if that worked then i can cut out a lot of stuff from my main file making my editing life a lot easier. also if you have a variable how can you write the content so over a few lines of your editor.
i want to do this

var chris = " content
content
content"

but it doesn't want to play seems like it has to be all on one line or you get an 'unterminated string constant error'
oh yeah a qucik one. if you have an array can you send a wildcard to that array so that what you are trying to do will apply to all of the array?

thanks guys

: : Relain : :

here i was alone in Las Vegas, completly twisted on drugs, no cash, no story for the magazine,i didn't even know who'd won the race, how would horatio aldrim have handled this situation....

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-20-2001 00:52

I've never tried calling a script and writing JS inside the tags but I don't think it will work.

For your other question

content \n content \n content

should work I put long variables all on one line.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-20-2001 19:16

According to JavaScript: The Definitive Guide (O'Reilly) by David Flanagan, "Any code that does appear between the open and close <script> tags is ignored by browsers that support the SRC attribute (although it is still executed by browsers like Navigator 2 that do not recognize the tag)."

As for the string thing you mentioned, bit was right that if you want to create line breaks in your string, you just use "\n", but if you want to make your string this way in order to make your code easier to read, you gotta do this:

mystring = "hi ";
mystring += "there ";
mystring += "Slime!";

If you want to do the same thing to every element of an array, you must do something like this:

var myArray = new Array(0,1,5,2,4,56,1,5,54,1,4,3);
for (a=0; a < myArray.length; a++)
{
myArray[a] += 3; // adds 3 to every array element.
}

kars10
Bipolar (III) Inmate

From: Europe
Insane since: Mar 2001

posted posted 08-21-2001 17:37

I was bugging Mr.Max twice because of this problem and he send me to a real cool site that works with all that stuff but, uhm, let's say that was too professional for me... Max, remember which? something about DynApi or so, right? hehe...
Anyhow, you can put some functions in a .js file and call them from the actual .html page...
here
<script language="JavaScript" type="text/JavaScript" src="thefolderinwhichyousavedthejsfile/thejsfile.js">
(dont write stuff in here!)
</script>

Let's say in that fil there is a function called browser() returning all kinds of information about this browser...
well, just include a new JavaScript tag (It ignores everthing in the first one, because you refere to another file)
<script language="JavaScript" type="text/JavaScript">
codecode code code code...
var browser=browser();
</script>

BTW, watch for diffrent function names. other wise it could get messed up. that's why I name functions in such files always with a "api".
BTW, This is called an API (Application Programing Interface).

kars10

PS: SLime, I DO love that book!

<A HREF="http://www.kars10.de/mobile/kb.gif
[b]only" TARGET=_blank>http://www.kars10.de/mobile/kb.gif
only</A> change remains

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 08-21-2001 19:28

I've seen sites that put the <noscript> stuff in between the <script> tags, but put the actual code in external files. That should work.

« BackwardsOnwards »

Show Forum Drop Down Menu