HREF URL无法正常工作

时间:2014-08-25 04:13:38

标签: javascript html

我正在尝试使用以下链接。

<a href='#' onclick='window.open(" | &ESPP_Info_URL | ");return false;'>Employee Stock Purchase Plan Information</a>

基本上&amp; ESPP_Info_URL变量接受一个url,以便下面的代码看起来像...

<a onclick="window.open(https://...);return false;" href="#">Employee Stock Purchase Plan Information</a>

但是当我点击网址时,它只刷新页面。有谁知道如何访问window.open函数中的链接?

2 个答案:

答案 0 :(得分:1)

试试这个,你需要用单引号'包裹网址 - window.open('YOUR URL HERE')

<a onclick="window.open('YOUR URL HERE');return false;" href="#">Employee Stock Purchase Plan Information</a>

答案 1 :(得分:0)

这是一个具有更多动态功能的扩展版本,jic: http://jsfiddle.net/ofnh7gke/

小版本: http://jsfiddle.net/rqf3s72n/

<强>的Javascript

var sites = ['http://www.google.com','http://www.github.com'];
document.getElementById('btnStockPurchasePlan').onclick = function(){
    window.open(sites[0],'_parent');
    return false;
};

<强> HTML

<a href='#' id="btnStockPurchasePlan">Employee Stock Purchase Plan Information</a>
相关问题