Jump to content

External JavaScript


Recommended Posts

i have a problem with were to put the

<script type="text/javascript" src="xxx.js"></script>

to make it work i want to put this script externa:

		<script language="JavaScript" type="text/javascript">		  <!--var r_text = new Array ();r_text[0] = "Stay away from crystals";r_text[1] = "Skilling is smart";r_text[2] = "All hail OverLOAD";r_text[3] = "If you see inco, your already dead";r_text[4] = "Obey Shadow man";r_text[5] = "Vorpals are you friend";r_text[6] = "Dont stay on a worm hole";r_text[7] = "Kill Pikaboo";var i = Math.floor(8*Math.random())document.write(r_text[i]);//--></script>

i am very new at this so i dont know what to do i want the Javascript external so i dont have to change it in 20 page'sbut if i put the <script type="text/javascript" src="xxx.js"></script> at the place of this script and save the javascrip in xxx.js nothing happencould anyone help thanks!all code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>index</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="keywords" content="fleet, npc's, production,space game, fleet, browser game, game, vorpal vang, skills, fleet help, buildings,pardus, pardus look alike, skilling, ships, newbie help, mmo"/><style type="text/css"> body {	 margin: 9px 9px 0 9px;	 padding: 0;	 background: #fff;	  }#level0 {	background: #fc0;	width: 100%; 		}		#level1 {	margin-left: 143px;	padding-left: 9px;	background: #fff;		}#level2 {	background: #fff3ac;	Position: relative;	width: inherit; 							}#main {	margin-right: 9em;	border-right: 1px solid #fc0;	padding-right: 9px;	background: #fff;		}#topbar {	background: #fc0;	width: 100%		  }#advbar {	background: #fff3ac; 	clear: right;	text-align: center;	  }#tipday {	float: right;	width: 175px;	background: #fff3ac;	position: relative; 	  }	#lftbar {	position: absolute;	width: 143px;	top: 9px;	left: 9px;	   }#rgtbar {	position: absolute;	width: 9em;	top: 0;	right: 0;	   }#main h1 {	margin: 0;	padding-left: .3em;	font: 1.25em verdana, helvertica, arial;	color: #609;	background: #fc0;	   }#main big {	margin: 0;	padding-left: .3em;	font: 1.25em verdana, helvertica, arial;	color: #609;	background: #fc0;	   }#main h2 {	margin: 0;	padding-left: .3em;	font: 1em verdana, helvertica arial;	color: #609;	background: #fc0;	}#main dt {	font-weight: bold;	font-size: 120%;	margin-top: .8em;	   }#rgtbar h3 {	margin: 0;	padding: 3px;	background: #fc0;	font-weight: bold;	font-size: 1em;	text-align: center;	   }#topbar form {	float: right;	width: 10.5em;	text-align: right;	margin: 0;	line-height: .7em;	   }#topbar input { font-size: .8em; }#topbar b {	display:block;	text-align: left;	font: bold .8em/1.7em arial, geneva, sans-serif;		}#tiptit {	width: 7em;	text-align: center;	position: absolute;	font: .8em/1.8em arial, geneva,sans-serif;	top:-1.8em;	right:0;		}#advbar p {	text-align: right;	margin: 0.5em;	font-weight: bold;		}#advbar img {	margin-bottom: 1em		 } a img {border:none;}   .note { color: red; }#footer {	 width: 100%;	 border-top: 1px solid #b9d2e3;	 border-bottom: 1px solid #b9d2e3;	 margin-top: 10px;	  }#footer p {	 font-size: 90%;	 color: #256290;	 margin: 0;	 padding: 0.2em 0 0.2em 0;	 }			#menu {width: 100%; /* set width of menu */background: #eee;z-index: 3;position: relative;} #menu ul { /* remove bullets and list indents */list-style: none;margin: 0;padding: 0;}/* style, color and size links and headings to suit */#menu a, #menu h2 {font: bold 11px/16px arial, helvetica, sans-serif;display: block;border-width: 1px;border-style: solid;border-color: #ccc #888 #555 #bbb;margin: 0;padding: 2px 3px;}#menu h2 {color: #fff;background: #000;text-transform: uppercase;}#menu a {color: #000;background: #efefef;text-decoration: none;}#menu a:hover {color: #a00;background: #fff;}#menu li {/* make the list elements a containing block for the nested lists */position: relative;} #menu ul ul ul {position: absolute;top: 0;left: 100%; /* to position them to the right of their containing block */width: 100%; /* width is based on the containing block */}div#menu ul ul ul,div#menu ul ul li:hover ul ul{display: none;}div#menu ul ul li:hover ul,div#menu ul ul ul li:hover ul{display: block;}</style></head><body><div id="lftbar">   <img width="143 em" alt="welcome to the Fleet fan page" src="images/fleet_s2.png" />      <script type="text/javascript">var ns = (navigator.appName.indexOf("Netscape") != -1);var d = document;function JSFX_FloatDiv(id, sx, sy){	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];	var px = document.layers ? "" : "px";	window[id + "_obj"] = el;	if(d.layers)el.style=el;	el.cx = el.sx = sx;el.cy = el.sy = sy;	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};	el.floatIt=function()	{		var pX, pY;		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 		document.documentElement && document.documentElement.clientWidth ? 		document.documentElement.clientWidth : document.body.clientWidth;		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 		document.documentElement.scrollTop : document.body.scrollTop;		if(this.sy<0) 		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 		document.documentElement.clientHeight : document.body.clientHeight;		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;		this.sP(this.cx, this.cy);		setTimeout(this.id + "_obj.floatIt()", 40);	}	return el;}JSFX_FloatDiv("menu",	   0,   75).floatIt();</script>  </div>      <div id="level0">   	<div id="level1">		 <div id="topbar">	   <form method="get" action="">		 <input type="text" name="query" size="12"/>		 <input type="submit" value="search"/>	   </form>	   <b>	   <a href="index.html">Home</a> ·	   <a href="gameinfo/gameinfo.html">Game Info</a> ·	   <a href="albume/albume.html">Album</a> ·	   <a href="#">Tools</a> ·	   	   <a href="aboute/aboute.html">About</a>	   </b>	  	 	  <div id="advbar">	  <object width="640" height="140"><param name="movie" value="img/miragebanner.swf"><embed src="img/miragebanner.swf" width="640" height="140"></embed></object>	  	  </div> 	 </div>	   <div id="level2">	   		<div id="rgtbar">			<h3>Help this site stay alive </h3><br /><br /><h3>Vote for Fleet</h3><div class="postbody"><a href="http://mpogtop.com/in/1296608982" class="postlink"><img src="http://mpogtop.com/images/mpogtop8831.jpg" alt="Image" /></a></div>		</div>		<div id="level3">				 <div id="main">		 <h1><span style="">Welcome to the Fleet fan site. </span></h1>				  <div id="tipday">			<div style="position:relative">				  <script language="JavaScript" type="text/javascript">		  <!--var r_text = new Array ();r_text[0] = "Stay away from crystals";r_text[1] = "Skilling is smart";r_text[2] = "All hail OverLOAD";r_text[3] = "If you see inco, your already dead";r_text[4] = "Obey Shadow man";r_text[5] = "Vorpals are you friend";r_text[6] = "Dont stay on a worm hole";r_text[7] = "Kill Pikaboo";var i = Math.floor(8*Math.random())document.write(r_text[i]);//--></script>				  <div id="tiptit">Tip of the Day</div>				</div>		  </div>		  <dl>		 		   <dt><a href="http://sylfex.redirectme.net/account.php" target="_blank"> Fleet</a > is a space combat and exploration game inspired by Pardus.</dt>		   <dd>In Fleet, you compete with other players to earn skills, credits, complete missions, and grow the strength, influence, and economies of yourself, your alliance, and your faction. </dd>		  </dl>		  		  <h1>What to find on this  site</h1>		  <p>here you can find all info  there is on Fleet </p>		  		  		   <h1>What is Fleet? </h1>   <p>Fleet is a revolutionary sci-fi real time strategy space themed web browser game. </p><p>It is designed to be fast, free, and fun. Fleet has a great deal of depth, complexity, and realism which allows you to explore the game and for your character to undergo continuous growth. </p><p>In Fleet, you role play the part of a future space explorer, while fighting other players and monster, either on your own, or with team mates to conquer territories, build an economy, and socialize.</p>    <h2>How do I play?</h2>  <p>  <p>Fleet supports mutliple game universes, so in order you play, you must first create an account, and then you must create a character in the game instance. </p>  <p>The current main game instance is called "Fleet Beta". Once you create and account, and click on the "Join" button in this universe, you can create a character and begin to play. </p>  <p>All new characters are automatically enrolled in the tutorial to give you a brief overview of the primary controls and information that comprise the core of Fleet. </p>  <p>New players are encouraged to see the help of other players in the Chat channels.</p>		  			</div>	  </div>	 </div>	</div>   </div> <div id="footer">     <center> <a href="http://jigsaw.w3.org/css-validator/check/referer">		<img style="border:0;width:88px;height:31px"			src="http://jigsaw.w3.org/css-validator/images/vcss"			alt="Valid CSS!" />	</a>Copyright 2011 - All Rights Reserve	<a href="http://validator.w3.org/check?uri=referer"><img		src="http://www.w3.org/Icons/valid-xhtml10"		alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></center>   <center><sup>Site last updated 02-07-2011</sup></center></div> <!-- footer --></body>   </html>

Link to post
Share on other sites

sorry, didn't see the document.write line. You can put the array in an external script file, and the just include document.write within script tags where ever you want that line to show up.

<script type="text/javascript">document.write(r_text[i]);</script>

Link to post
Share on other sites

If you learn a server-side language, then you can construct your page such that one change will appear in all.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...