简体   繁体   English

href =“ javascript:”在新标签页中打开

[英]href=“javascript:” open in new tab

I am working on a website where the developer used href="javascript" for the links. 我正在一个网站上,开发人员使用href =“ javascript”作为链接。 I need the links to open in a new tab when the user clicks on them but when I make the target equal to _blank or the base equal to _blank a new tab opens but nothing is on the page. 当用户单击链接时,我需要在新选项卡中打开链接,但是当我使目标等于_blank或基准等于_blank时,将打开一个新选项卡,但页面上没有任何内容。 The links themselves go to an external site. 链接本身将转到外部站点。

Can someone explain to me why this is and how I could possibly get the links working properly? 有人可以向我解释为什么会这样,以及如何使链接正常工作吗?

Example of one of the links: 链接之一的示例:

<a href="javascript:SubmitPurchaseLink('Ticks1545037499', '%7eYn%7eJva2%7eVya%7eW%7eQ9%7eM%7eTc2%7eM%7eS%7eZza%7eX%7eRlbn%7eVt%7eYm%7eVy%7eP%7eT%7eE4%7eJn%7eRna%7eW%7eQ9%7eM%7eT%7eU0%7eN%7eT%7eAz%7eNz%7eQ5%7eO%7eS%7eZldn%7eRp%7eZ%7eD0y%7eN%7eD%7eIy%7eMz%7eA4%7eJn%7eBya%7eW%7eNl%7eP%7eT%7eEy%7eN%7eS4w%7eM%7eD%7eAw%7eJm%7eN1cn%7eJlbm%7eN5a%7eW%7eQ9%7eM%7eQ..!%7eB2pn%7eE%7eJ%7eIv%7eSts.')">

You need to modify the SubmitPurchaseLink function and within that function need to open target URL to a new tab. 您需要修改SubmitPurchaseLink函数,并且在该函数中需要打开目标URL到新选项卡。

function SubmitPurchaseLink() {
  // your code

  // code to open URL to a new window
  window.open(url, '_blank');   
}

Ref: window.open 参考: window.open

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM