Solved

JavaScript for target=_top

Posted on 2007-12-06
4
3,040 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

803 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