external javascript

liunx

Guest
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><br />
i have 12 items to display in different pages.instead of using 12 pages, i wanna use 2 pages. so i have to use an external javascript.but i don't know how to use it and where to put. <br />
please help me.<!--content-->Using JavaScript will not work for the 13% of users who do not browse with JavaScript enabled. Do you have any serverside langagues available? PHP? SSI? You could use them to include the file.<!--content-->[email protected] <br />
thank you.<br />
but the thing is i don't have neither of them.<br />
is there any other ways for me to achieve the same result?:confused: <br />
but any way,thank you all the same.;)<!--content-->Find a new host...<br />
<br />
Apart from that, using JavaScript to include content is a bad idea... But, if you really want me to tell you, I can.<!--content-->you know what? i can't stop smiling.you are so nice.<br />
the thing is i am learning it now. it is a project and have to submit in the next 36hs.<br />
i don't much about the whole thing.<br />
so i think it's easier to use javascipt.<br />
what's your suggestion?<!--content-->Here's how you reference an external .js file:<br />
<br />
<script type="text/javascript" src=http://www.webdeveloper.com/forum/archive/index.php/"script.js"></script><br />
<br />
And in script.js, you will want to put something like this:<br />
<br />
document.write('<p>This is the first line</p>',<br />
'<p>this is the second line</p>',<br />
'<this is the third line</p>',<br />
'<p>etc...</p>');<!--content-->oh.i did that.<br />
items.js<br />
<br />
var items = [ <br />
[1, "Action"], <br />
[2, "Comedy"], <br />
[3, "Drama"] <br />
];<br />
the thing is when i import the items.js and try to browse it.an error message states taht items.js is null or not an object.<!--content-->What's the rest of the code look like? Also, are you sure you have the path to the external file correct?<!--content-->details03.html<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www1.w3.org/TR/REC-html40/loose.dtd"><br />
<html><br />
<head><br />
<title>untitled</title><br />
<style><br />
.big { font-size: 20pt; color: red; }<br />
.bigger { font-size: 30pt; color: green; }<br />
</style><br />
</head><br />
<br />
<body><br />
<script src=http://www.webdeveloper.com/forum/archive/index.php/"items.js" language="javascript" ></script><br />
<div class="big"><br />
<script><br />
<br />
var x = location.search;<br />
var y = x.split("=");<br />
<br />
for(var i in items){<br />
if (y[1] == items[0])<br />
document.write(items[1]);<br />
}<br />
</script><br />
<br />
</div><br />
<hr><br />
<div class="bigger">Bla... Bla... Bla.... </div><br />
</body><br />
</html><br />
<br />
<br />
<br />
products.html<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<html><br />
<head><br />
<title>Untitled Document</title><br />
<script src=http://www.webdeveloper.com/forum/archive/index.php/"items.js"></script><br />
<script><br />
for (var i in items) {<br />
document.writeln("<a href='http://www.webdeveloper.com/forum/archive/index.php/details03.html?code=" + items[0] + "'>");<br />
document.writeln( items[1] );<br />
document.writeln("</a>");<br />
document.writeln("<br>");<br />
}<br />
</script><br />
</head><br />
<br />
<body><br />
</body><br />
</html><br />
<br />
what do you mean by the path?<!--content-->in <script type="text/javascript" src=http://www.webdeveloper.com/forum/archive/index.php/"items.js"></script> are you sure that items.js exists in the same directory as the html pages?<!--content-->oh.i see.but i always have problem with directries.can you tell me how to manage it properly.<br />
thank you.<!--content-->You could do this, to be sure it works from wherever you try to access it:<br />
<br />
<script type="text/javascript" src=http://www.webdeveloper.com/forum/archive/index.php/"http://www.yourdomain.com/directory/items.js"></script><!--content-->thank you very much. <br />
:D :D :D :D :D :D <br />
thank you.<!--content-->You bet... :)<!--content-->
 
Back
Top