如何在 JavaScript 中重定向到同一窗口中的另一个页面

how to redirect to another page in same window in javascript

本文关键字:窗口 另一个 JavaScript 重定向      更新时间:2023-09-26

我正在创建一个应用程序,其中我正在使用图像过渡幻灯片。 在图像幻灯片中,我使用超链接转到另一个页面。 但是页面在新窗口中打开。 我想在同一窗口中打开页面。

flashyslideshow.prototype.getSlideHTML=function (index) {
    var slideHTML= (this.imagearray[index][1])?'<a href=  "' + this.imagearray[index][1]+'" target = "'+this.imagearray[index][2]+ "_self" '">'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
}

<a>标签内,添加

target="_self"

这将强制链接在同一窗口中打开。

<a href="www.google.com" target="_self">Google</a>

您可以通过确保目标为空来实现这一点,如下所示

<form id="form" method="post" action="index.html">