Closed Thread Icon

Topic awaiting preservation: javascript & linking Pages that link to <a href="https://ozoneasylum.com/backlink?for=8092" title="Pages that link to Topic awaiting preservation: javascript &amp;amp; linking" rel="nofollow" >Topic awaiting preservation: javascript &amp; linking\

 
Author Thread
Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 02-23-2002 23:19

I want to put urls into a javascript array "i think", and then call them in my page, If I'm way off on this or you dn't understand what I mean let me know...

Mabye somthing like this?

var xtrae1 = new Array(7)
xtrae1[0] = "home.html"
xtrae1[1] = "services.html"
xtrae1[2] = "clients.html"
xtrae1[3] = "links.html"
xtrae1[4] = "photos.html"
xtrae1[5] = "graphics.html"
xtrae1[6] = "contacts.html"

document.write("<A Href="+xtrae1+"</a>")

but how do I tell it which link to display, how do I call the varable? and what do I put on the page to call it?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 02-23-2002 23:40

Study this:

<script ... >
for (linknum = 0; linknum < xtrae1.length; linknum++)
{
document.write('<a href="' + xtrae1[linknum] + '">' + xtrae1[linknum] + '</a><br>');
}
</script>

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 02-24-2002 01:04

thanks a bunch, At least I was working in the right direction

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 02-24-2002 02:18

I think I got that part, but what about if I need to do something this?

If I put this is in an external script.js file
--------------------------------------------------------------------
function dotheFunc()
{
var a = "http://www.xtrae.com/home.html"
var b = "http://www.xtrae.com/home.html"
var c = "http://www.xtrae.com/services.html"
var d = "http://www.xtrae.com/clients.html"
var e = "http://www.xtrae.com/links.html"
var f = "http://www.xtrae.com/photos.html"
var g = "http://www.xtrae.com/graphics.html"
var h = "http://www.xtrae.com/contacts.html"
}

-----------------------------------------------------------------------------
then could I do this on the page to display the link I choose?

<a href="JavaScript:dotheFunc('var a');">Home</a>
------------------------------------------------------------------------------
and do I need to do this in the head?
<SCRIPT language="JavaScript" SRC="scripts/script.js"></SCRIPT>
----------------------------------------------------------------------------



[This message has been edited by Synthetic (edited 02-24-2002).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 02-24-2002 05:06

Yes, you'd need to include the link to the external .js file.

I don't think your method would work. You'd need to do something like:

<script type="text/javascript" language="javascript">
var xtrae1 = new Array(7)
xtrae1[0] = "home.html"
xtrae1[1] = "http://www.gurusnetwork.com"
xtrae1[2] = "clients.html"
xtrae1[3] = "links.html"
xtrae1[4] = "photos.html"
xtrae1[5] = "graphics.html"
xtrae1[6] = "contacts.html"

function goTo(site){
// alert(xtrae1[site]);
document.location.href = xtrae1[site];
}
</script>

<a href="javascript:void(0)" onclick="goTo(1);">Click me or die</a>


That's off the top of my head, so may need to tweak it a little.

« BackwardsOnwards »

Show Forum Drop Down Menu