简体   繁体   中英

How do i make the generated link anchor text only?

I plan on sharing this to a Facebook group I'm in but I want the link that is generated from putting in the information to be text only and not the url. How can I do this?

 <style> a:link, a:visited { background-color: #f44336; color: white; padding: 14px 25px; text-align: center; text-decoration: none; display: inline-block; } a:hover, a:active { background-color: red; } </style>
 <head> <script type="text/javascript"> function generateLink() { let link = document.getElementById('link'); let Group = document.getElementById('GroupID'); let User = document.getElementById('UserID'); let link_string = 'https://m.facebook.com/group/block/?group_id=' + Group.value + '&user_id=' + User.value; link.innerHTML = '<a href=' + encodeURI(link_string) + '>' + encodeURI(link_string) + '</a>'; } </script> </head> <body> Group ID Number: <input type='text' id='GroupID' onkeyup='generateLink();' /> <br>The Group ID Number is the first set of numbers in the url https://www.facebook.com/groups/<mark>Group ID Number</mark>/user/User ID Number<br><br> User ID Number: <input type='text' id='UserID' onkeyup='generateLink();' /><br> The User ID Number is the second set of numbers in the url https://www.facebook.com/groups/Group ID Number/user/<mark>User ID Number</mark> <br><br> <span id='link'></span><br><br> <a href="https://lookup-id.com/" target="_blank">I don't know what the Group or User ID Number is</a> <br><br> </body>

How do I make the generated link to be a clickable text link only?

I don't really understand your question.

Do you want it to look like pure text but clickable?

Use CSS: color: black and text-decoration: none

 link.innerHTML =  '<a href=' + encodeURI(link_string) + '>' + "FaceBook Group" + '</a>';

像这样写

I figured it out.

I removed

'>' + encodeURI(link_string) +

from the below code (part in bold)

link.innerHTML = '<a href=' + encodeURI(link_string) + '>' + encodeURI(link_string) + '</a>';

which changes it to

link.innerHTML =  '<a href=' + encodeURI(link_string) + '</a>';

Then I added quotes after <a href= and before </a>'; to make it look like this.

link.innerHTML = '<a href= " ' + encodeURI(link_string) + ' " </a>';

Then I added a > after the second ending quote.

link.innerHTML = '<a href="' + encodeURI(link_string) + '" > </a>';

Finally I added the text between >< which looks like this.

link.innerHTML = '<a href= "'+ encodeURI(link_string) + '" > Block User </a>';

Now it does exactly what I want.

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