自定义链接的打开方式

Customize how links are opened

本文关键字:方式 链接 自定义      更新时间:2023-10-18

下面的代码从javascript生成的url中检索链接列表(http://us1.campaign-archive2.com/generate-js/?u=37e5f50ea5a65008de12f2e48&fid=47053&显示=10)

有没有办法使用下面的代码在同一页的框架中打开链接,而不是在新的选项卡中?

<style type="text/css">
<!--
.display_archive {font-family: arial,verdana; font-size: 12px;}
.campaign {line-height: 125%; margin: 5px;}
//-->
</style>
<script language="javascript" src="http://us1.campaign-archive2.com/generate-js/?u=37e5f50ea5a65008de12f2e48&fid=47053&show=10" type="text/javascript"></script>

您需要从<a>标记中删除target="_blank"属性。

现在页面上的所有链接的格式如下:

 <a href="http://..." title="Anything" to="" celebrate="" ?="" 
    find="" the="" right="" location="" 
    target="_blank">
       Anything to Celebrate ? Find the right Location
 </a>

如果删除target属性,则所有链接都将在同一窗口中打开。

要从JavaScript打开url,只需使用:

location.href = "http://...";

默认情况下,浏览器会在同一窗口中打开新的url。