Web Hosting Talk







View Full Version : Need Javascript Coding Assistance


croakingtoad
03-31-2003, 08:03 AM
Okay, below you'll see a javascript that I have but I need it modified slightly. You can see what this script does by visiting http://www.croakingtoad.com/templates.shtml.

When you click the displayed thumbnail image, it opens the matching full-size image in the browser window.

What I want it to do, is open first of all in a new window. I also want more control over that window by javascript. Something like: window.open("photoslink[which]","new_window","scrollbars,resizable");

I don't know if that above syntax is 'exactly' right, but you probably get the idea... Can somebody take a look at the javascript as is and suggest how to get it to perform the above? Thanks!

Here it is:


<script language="JavaScript1.1">

/*
DHTML slideshow script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var photos=new Array()
var photoslink=new Array()
var which=0

//define images. You can have as many as you want. Images MUST be of the same dimensions (for NS's sake)
photos[0]="/templates/thumbs/spx1_thumb.jpg"
photos[1]="/templates/thumbs/spx2_thumb.jpg"
photos[2]="/templates/thumbs/spx3_thumb.jpg"
photos[3]="/templates/thumbs/spx4_thumb.gif"
photos[4]="/templates/thumbs/spx5_thumb.gif"

//Specify whether images should be linked or not (1=linked)
var linkornot=1

//Set corresponding URLs for above images. Define ONLY if variable linkornot equals "1"
photoslink[0]="/templates/spx1.jpg"
photoslink[1]="/templates/spx2.jpg"
photoslink[2]="/templates/spx3.jpg"
photoslink[3]=""
photoslink[4]=""

//do NOT edit pass this line

var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
}


function applyeffect(){
if (document.all){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
photoslider.filters.revealTrans.stop()
photoslider.filters.revealTrans.apply()
}
}



function playeffect(){
if (document.all)
photoslider.filters.revealTrans.play()
}

function keeptrack(){
window.status="Image "+(which+1)+" of "+photos.length
}


function backward(){
if (which>0){
which--
applyeffect()
document.images.photoslider.src=photos[which]
playeffect()
keeptrack()
}
}

function forward(){
if (which<photos.length-1){
which++
applyeffect()
document.images.photoslider.src=photos[which]
playeffect()
keeptrack()
}
}

function transport(){
window.location=photoslink[which]
}

</script>

digitok
03-31-2003, 08:22 AM
Try changing:

function transport(){
window.location=photoslink[which]
}

----------------------------------------------------

To this:

function transport() {
window.open(photoslink[which], 'image', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no');
}

----------------------------------------------------

I don't know too much JavaScript, I had to read up on that just now, since I only know a few of the functions/operators :P Get back to me and tell me if it's what you needed or not...

croakingtoad
04-02-2003, 08:53 PM
You da man. Worked great, thanks!

:D

-------------------------------


Now, here's my second question. Is there any way to assign a variable to the photos[X] so that when the window pop's up, I can have some text typed below the image?

Does that make sense??

croakingtoad
04-03-2003, 10:14 PM
Any help on my second question?

digitok
04-03-2003, 10:23 PM
Oh, sorry :P
You'd probably have to change the window.open() code to open in a page that you create, eg. blah.php?img=#, then make a small PHP script that shows that image and the specific text