Solved

JavaScript for target=_top

Posted on 2007-12-06
4
3,035 Views
Last Modified: 2008-02-21
I'm using the current script below but instead of having var newwindow=1 i need the target window to be _top as this scipt is currently sitting in an iframe.

any advice please?
thanks!


<script language="JavaScript1.2">
<!--
//specify interval between slide (in mili seconds)
var slidespeed=2000

//specify images
var slideimages=new Array("promosmall1.gif","promosmall2.gif","promosmall3.gif","promosmall4.gif")

//specify corresponding links
var slidelinks=new Array("specials4.asp?id=41&page=4","specials2.asp?id=14&page=2","specials5.asp?id=53&page=5","specials.asp?id=1&page=1")

var newwindow=1 //open links in new window? 1=yes, 0=no

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow2(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}

//-->
</script>
      <a href="javascript:gotoshow2()"><img src="../images/promos/promosmall1.gif" name="slide" border=0 align="top" style="filter:blendTrans(duration=3)"/></a>
              <script language="JavaScript1.2">
                        <!--
                        var whichlink=0
                        var whichimage=0
                        var blenddelay=(ie)? document.images.slide.filters[0].duration*1000 : 0
                        function slideit(){
                        if (!document.images) return
                        if (ie) document.images.slide.filters[0].apply()
                        document.images.slide.src=imageholder[whichimage].src
                        if (ie) document.images.slide.filters[0].play()
                        whichlink=whichimage
                        whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
                        setTimeout("slideit()",slidespeed+blenddelay)
                        }
                        slideit()
                        //-->
                  </script>            
0
Comment
Question by:clandestine
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20425973
window.open(slidelinks[whichlink],"_top")
else
top.location=slidelinks[whichlink]
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
ID: 20425978
Or better if you want to keep current functionality

var newwindow=1 //open links in new window? 1=yes, 0=no
var windowName = "_top"
.
.
.

function gotoshow2(){
if (newwindow)
window.open(slidelinks[whichlink],windowName)
else
window.location=slidelinks[whichlink]
}


0
 
LVL 1

Expert Comment

by:Computer101
ID: 20953166
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now