0

Good Day:

I'm working with an image changing javascript that allows you to click on an image to open a URL.

The problem I'm having is that when I click on the image, it opens the said URL in a new window. I want it to open in the parent window.

Here is my inline javascript in the head tags:

<script language="JavaScript1.1">
<!--
var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
	for (i=0;i<slideshowimages.arguments.length;i++){
		slideimages[i]=new Image()
		slideimages[i].src=slideshowimages.arguments[i]
		}
	}
function slideshowlinks(){
	for (i=0;i<slideshowlinks.arguments.length;i++)
	slidelinks[i]=slideshowlinks.arguments[i]
	}
function gotoshow(){
	if (!window.winslide||winslide.closed)
	winslide=window.open(slidelinks[whichlink])
	else
	winslide.location=slidelinks[whichlink]
	winslide.focus()
	}
//-->
</script>

And here is my javascript in the body tags:

<script>
//configure the paths of the images, plus corresponding target links if you want
slideshowimages("image1.png","image2.png","image3.png","image4.png")
slideshowlinks("page1.php","page2.php","page3.php","page4.php")

//configure the speed of the slideshow, in miliseconds
    var slideshowspeed=4000
    var whichlink=0
    var whichimage=0
    function slideit(){
    if (!document.images)
         return
         document.images.slide.src=slideimages[whichimage].src
         whichlink=whichimage
    if (whichimage<slideimages.length-1)
         whichimage++
    else
         whichimage=0
         setTimeout("slideit()",slideshowspeed)
    }
slideit()
</script>

I've already tried various things related to adding name as a var, setting it to _parent, inserting a new function to get name, etc...
All to no avail.

Any help would be greatly appreciated.

Best Regards,
dennishall

Edited by dennishall: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by dennishall
0
window.open("www.google.com", "_parent")

will make the page open in the same window. so according to your code this should work :

winslide=window.open(slidelinks[whichlink], "_parent")

You have said u have tried, it, so from the code that u have provided i cant see what could be wrong, please provide the full html as well,

0

I have resolved this issue myself. For the record, the only html required was to create the containing div; as follows:

<div id=photoSlider></div>

To correct it, I inserted into line 10 of the head:

var names=new Array()

And added a new function into line 15 of the head:

function slideshownames(){  for (i=0;i<slideshownames.arguments.length;i++)  names[i]=slideshownames.arguments[i]    }

I then modified lines 17 and 19 to:

winslide=window.open(slidelinks[whichlink][whichnames])
winslide.location=slidelinks[whichlink][whichnames]

Finally, I inserted the following into the body script at line 5 :

slideshownames("_parent","_parent","_parent","_parent")

then into the body script at line 10:

var whichnames=0

then inserted into line 15:

whichimage=whichnames

... and it all works fine now :).

Thanks for the information above anyhow Thirusha, the goal was to have it work with your resulting code above, so you were bang on as to what I wanted to acheive.

Next time I won't forget including the html code when asking for help.

Best Regards,
dennishall

Edited by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.