Click to See Complete Forum and Search --> : How to direct w/c Array to Open


Four_of_Five
02-19-2003, 01:52 AM
I seem to be unable to successfully get this particulary script to work on multiple links...enways...
The script below makes a clicked link or links slowly uhmm..unfold an htmdoc on a new window:

__________________________________________________________
<head>
<script>
var mylocationArray= new Array('1sthtmdoc.htm', '2ndhtmdoc.htm')
var winheight=100
var winsize=100
var x=5

function go(){
win2=window.open(mylocationArray[0],"","scrollbars")
if (!document.layers&&!document.all){
win2.location=mylocationArray[0]
return
}
win2.resizeTo(100,100)
win2.moveTo(0,0)
go2()
}
function go2(){
if (winheight>=screen.availHeight-3)
x=0
win2.resizeBy(5,x)
winheight+=5
winsize+=5
if (winsize>=screen.width-5){
win2.location=mylocationArray[1]
winheight=100
winsize=100
x=5
return
}
setTimeout("go2()",50)
}

</script>
</head>
And in between the <body></body>:
<a href="javascript:go()"
onMouseover="window.status='open window';return true" onMouseout="window.status=''">TextLink 1 here</a>
_______________________________________________________
My questions are: How do have the script open the corresponding .htm document for each text link i want??

And what if I need to add more links? w/c values should i need to change

TIA!

gil davis
02-19-2003, 06:08 AM
You could save yourself a lot of grief by using a link that has the page as it's href:

<a href="1sthtmdoc.htm"
target="_blank"
onclick="go(this.href);return false"
...>

And change the function:

function go(url) {
win2 = window.open(url, "win2", "scrollbars=1,resizable=1");
if (!document.layers && !document.all) {
win2.location.href = url;}
win2.resizeTo(100,100);
win2.moveTo(0,0);
go2();
}

This allows people without JavaScript to still see the page. If the user does not have JavaScript, clicking the link will cause the page to open in a new window.

You can have as many links as you want without changing anything in the script.

Four_of_Five
02-19-2003, 01:38 PM
Thanks Gil...but ...Uhmm..well, am not sure i understand...i tried applying the changes you suggested..but it didnt turn out quite right...i mean it did launch a new window with the corresponding htm doc...but it kinda lost it's "effect"... well...dunno i must have screwed up the sequence...

in any case, I would prefer very much to have the original script followed rather than changing it...coz it is also more of a question on how to get the "arrays" to work not only of making the script work...coz it works fine except it does open only one htmlink doc....dunno maybe I prefer the grief :rolleyes:

Thanks for the suggestion...

gil davis
02-19-2003, 03:07 PM
I didn't look close enough at the function go2(). I didn't realize it changed the location once it got big. I assumed you wanted one page to open slowly from a link and stay big.

To add more pages, you just have to add them to the array. Go back to what you had originally. Then in the function go2() change this line:win2.location=mylocationArray[1]to:

win2.location = mylocationArray[pg];
pg = (pg + 1) % (mylocationArray.length - 1);

and along with your other vars, add this:

var pg = 0;

This will run through as many pages as there are entries in the array forever. If that's not what you want, then post again.

Four_of_Five
02-19-2003, 03:54 PM
win2.location = mylocationArray[pg];

I'm assuming i'll retain every other part of the script except those w/c u suggested changed right? And uhmm....
This is kinda silly...and perhaps a bit too early for me to ask...but what does "pg" stand for? or does it stand for anything?
:rolleyes:

It's not "parental guidance"...hehehe :)...again, thanks for your "pg"...patient guidance!
I'll have to

gil davis
02-19-2003, 06:26 PM
I'm assuming i'll retain every other part of the script except those w/c u suggested changedYes. Go back to what you first posted, but make the changes - actually change one line and add two additional lines.

BTW, what does "w/c" stand for?what does "pg" stand for?
What I had in mind was the abbreviation for "page". You can call it anything you want.

Four_of_Five
02-20-2003, 10:16 AM
Hello again,

Well, it worked...but i didnt exactly follow your second advice. I think you were already on the right track with the first one...using the go.(url) thing much easier.. besides, i kinda got my docfiles mixed up...and the arrays were kinda bad idea in the first place...

Eneways, many thanks again for your inputs...and the txtscript is attach should you be interested to find out how it turned out...


PS: oh yeah, "w/c" is an abbreviation for "which" :)...w/c reminds me...im hungry.. i need a sandw/c (get it?)