Solved

JavaScript for target=_top

Posted on 2007-12-06
4
3,032 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
Comment Utility
window.open(slidelinks[whichlink],"_top")
else
top.location=slidelinks[whichlink]
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
Comment Utility
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
Comment Utility
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now