简体   繁体   中英

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. My JavaScript code :

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

Why javascript? Use the 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

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)

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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