如何重定向到同一窗口中的另一个页面 [英] how to redirect to another page in same window
本文介绍了如何重定向到同一窗口中的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我使用图像过渡幻灯片.在这种情况下,我通过了单击图像过渡上的超链接.当我单击图像时,它会转到另一页,但会在新窗口中打开.我想在同一窗口中打开它.在下面编写JavaScript代码.
html pgge
in my application i m use image transitions slideshow . in that i am passed hyperlink on click on image transition. when i clicked on image it goes to another page but it open in new window . i want to open it in same window. below write javascript code.
html pgge
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="js/transitionshow.js"></script>
<script type="text/javascript" src="js/transitionshow1.js"></script>
<style type="text/css">
.flashclass{ /*sample CSS class added to image slideshow container*/
width:100%;
/*a width should be defined for transition to work*/
/*border: 5px solid orange;*/
padding: 0px;
}
</style>
<style type="text/css">
.body
{
border-style:solid;
border-width:1px;
margin-left:5px;
margin-right:5px;
margin-top:5px;
margin-bottom:5px;
border-color:Black;
width:100%;
}
</style>
</HEAD>
<BODY class ="body">
<table width="100%" cellspacing="0" cellpadding="0" align="center" >
<tr>
<td align="right" width="45%" >
<script type="text/javascript">
var flashyshow = new flashyslideshow({ //create instance of slideshow
wrapperid: "myslideshow", //unique ID for this slideshow
wrapperclass: "flashclass", //desired CSS class for this slideshow
imagearray: [
["images/techno1.jpg","page2.html"],
["images/techno2.jpg",""],
["images/techno3.jpg",""]
///["images/Fotolia_19011881_L.jpg", "http://www.aarambhinnovationals.com", "_new", ""]
],
pause: 1000, //pause between content change (millisec)
transduration: 1000 //duration of transition (affects only IE users)
}
)
</script>
</td>
<td >
<script type="text/javascript">
var flashyshow = new flashyslideshow({ //create instance of slideshow
wrapperid: "myslideshow1", //unique ID for this slideshow
wrapperclass: "flashclass", //desired CSS class for this slideshow
imagearray: [
["images/healing1.jpg",""],
["images/healing2.jpg",""],
["images/healing3.jpg",""]
///["images/Fotolia_19011881_L.jpg", "http://www.aarambhinnovationals.com", "_new", ""]
],
pause: 1000, //pause between content change (millisec)
transduration: 1000 //duration of transition (affects only IE users)
}
)
</script>
</td>
<td align="left" width="55%" >
<script type="text/javascript">
var flashyshow = new flashyslideshow({ //create instance of slideshow
wrapperid: "myslideshow2", //unique ID for this slideshow
wrapperclass: "flashclass", //desired CSS class for this slideshow
imagearray: [
["images/innovative1.jpg",""],
["images/innovative2.jpg",""],
["images/innovative3.jpg",""]
///["images/Fotolia_19011881_L.jpg", "http://www.aarambhinnovationals.com", "_new", ""]
],
pause: 1000, //pause between content change (millisec)
transduration: 1000 //duration of transition (affects only IE users)
}
)
</script>
</td>
</tr>
</table>
</BODY>
</HTML>
javascript代码
javascript code
var global_transitions=[ //array of IE transition strings
"progid:DXImageTransform.Microsoft.Fade()"
]
function flashyslideshow(setting){
this.wrapperid=setting.wrapperid
this.imagearray=setting.imagearray
this.pause=setting.pause
this.transduration=setting.transduration/1000 //convert from miliseconds to seconds unit to pass into el.filters.play()
this.currentimg=0
var preloadimages=[] //temp array to preload images
for (var i=0; i<this.imagearray.length; i++){
preloadimages[i]=new Image()
preloadimages[i].src=this.imagearray[i][0]
}
document.write('<div id="'+this.wrapperid+'" class="'+setting.wrapperclass+'"><div id="'+this.wrapperid+'_inner" style="width:100%">'+this.getSlideHTML(this.currentimg)+'</div></div>')
var effectindex=Math.floor(Math.random()*global_transitions.length) //randomly pick a transition to utilize
var contentdiv=document.getElementById(this.wrapperid+"_inner")
if (contentdiv.filters){ //if the filters[] collection is defined on element (only in IE)
contentdiv.style.filter=global_transitions[effectindex] //define transition on element
this.pause+=setting.transduration //add transition time to pause
}
this.filtersupport=(contentdiv.filters && contentdiv.filters.length>0)? true : false //test if element supports transitions and has one defined
var slideshow=this
flashyslideshow.addEvent(contentdiv, function(){slideshow.isMouseover=1}, "mouseover")
flashyslideshow.addEvent(contentdiv, function(){slideshow.isMouseover=0}, "mouseout")
setInterval(function(){slideshow.rotate()}, this.pause)
}
flashyslideshow.addEvent=function(target, functionref, tasktype){
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false);
else if (target.attachEvent)
target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},
flashyslideshow.setopacity=function(el, degree){ //sets opacity of an element (FF and non IE browsers only)
if (typeof el.style.opacity!="undefined")
el.style.opacity=degree
else
el.style.MozOpacity=degree
el.currentopacity=degree
},
flashyslideshow.prototype.getSlideHTML=function(index){
var slideHTML=(this.imagearray[index][1])? '<a href= "' + this.imagearray[index][1]+'" target="' window.location = + this.imagearray[index][2]+'">\n' : '' //hyperlink slide?
slideHTML+='<img src="'+this.imagearray[index][0]+'" height="550" width="100%" >'
slideHTML+=(this.imagearray[index][1])? '</a><br />' : '<br />'
slideHTML+=(this.imagearray[index][3])? '<font face="bookman old style" color="blue" size="3">' + this.imagearray[index][3] : '' //text description?
return slideHTML //return HTML for the slide at the specified index
}
flashyslideshow.prototype.rotate=function(){
var contentdiv=document.getElementById(this.wrapperid+"_inner")
if (this.isMouseover){ //if mouse is over slideshow
return
}
this.currentimg=(this.currentimg<this.imagearray.length-1)? this.currentimg+1 : 0
if (this.filtersupport){
contentdiv.filters[0].apply()
}
else{
flashyslideshow.setopacity(contentdiv, 0)
}
contentdiv.innerHTML=this.getSlideHTML(this.currentimg)
if (this.filtersupport){
contentdiv.filters[0].play(this.transduration)
}
else{
contentdiv.fadetimer=setInterval(function(){
if (contentdiv.currentopacity<1)
flashyslideshow.setopacity(contentdiv, contentdiv.currentopacity+0.1)
else
clearInterval(contentdiv.fadetimer)
}, 50) //end setInterval
}
}
推荐答案
HTML的基础知识,
要在同一窗口中打开页面,请使用window.open("your URL","_self");
还要检查关于锚标签 [
Hi,
Very basic of HTML,
To open page in same window usewindow.open("your URL","_self");
Also check About Anchor tag[^]
Thanks
-Amit
这篇关于如何重定向到同一窗口中的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文