【问题标题】:target_blank property with javascript [duplicate]带有javascript的target_blank属性[重复]
【发布时间】:2017-11-30 12:38:54
【问题描述】:

document.getElementById("mahacareer").onclick = function () {
	location.href = "http://www.mahacareermitra.in";
};
<a href="" target="_blank" id="mahacareer">Access the portal</a>

你好,当我点击它时,我想在新标签中打开上面的链接。我们使用带有标签的 target="_blank" 属性,但我想在 JavaScript 中使用该属性。

【问题讨论】:

标签: javascript jquery html twitter-bootstrap css


【解决方案1】:

你可以使用

window.open('http://www.mahacareermitra.in','_blank');

您可以在java脚本中使用SetAttribute函数。

<a href=""  id="mahacareer">Access the portal</a>

试试这个

  document.getElementById("mahacareer").setAttribute("target", "_blank"); 

【讨论】:

    猜你喜欢
    • 2013-11-21
    • 1970-01-01
    • 2010-09-08
    • 2010-09-08
    • 1970-01-01
    • 2016-05-04
    • 2016-04-01
    • 2017-08-17
    • 2013-10-27
    相关资源
    最近更新 更多