Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JavaScript for target=_top

Posted on 2007-12-06
4
Medium Priority
?
3,072 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 1200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

926 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