简体   繁体   English

如何隐藏超链接下划线并在javascript中保持原字体颜色?

[英]How to hide the hyperlink underline and maintain the origin font color in javascripts?

How to hide the hyperlink underline and maintain the origin by avoid change to blue color font in JavaScript. 如何通过避免在JavaScript中更改为蓝色字体来隐藏超链接下划线并保持原点。 My JavaScript code : 我的JavaScript代码:

<a href="javascript:window.open('selectprofiletype.php','Crm.com - Create',
'width=700,height=350' ) ">&nbsp;&nbsp;User Profile</a>

Why javascript? 为什么要使用JavaScript? Use the CSS. 使用CSS。

a {
  text-decoration: none;
  color: black;
}

Hope this helps: 希望这可以帮助:

a {
    color: #0060B6;
    text-decoration: none;
}

a:hover 
{
     text-decoration:none; 
     color: #0060B6;
     cursor:pointer;  
}

this seems more like a css question 这似乎更像一个css问题

a{
text-decoration: none; 
color: your colour here;
}

Please change the JavaScript to the following (and use any of the other answers for the CSS instead of using an inline style) 请将JavaScript更改为以下内容(并为CSS使用其他任何答案,而不要使用内联样式)

<a href="selectprofiletype.php" target="crm_create" style="text-decoration:none"
onclick="var w = window.open(this.href,this.target,'width=700,height=350');
  return w?false:true;">&nbsp;&nbsp;User Profile</a>

since your code will give problems in several browser - for example the window name may not have spaces 因为您的代码将在多个浏览器中出现问题-例如,窗口名称可能没有空格

The code would be nicer if unobtrusive: 如果不引人注意,该代码会更好:

window.onload=function() {
 document.getElementById("crm").onclick=function() {
  var w = window.open(this.href,this.target,'width=700,height=350');
  return w?false:true;
 }
}

using just 仅使用

<a id="crm" href="selectprofiletype.php" target="crm_create">User Profile</a>

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

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