• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

Printer Friendly Javascript Remove Links

I have a javascript function for a printer friendly page.  The only problem is that hyperlinks show up in the printer friendly page.  I need the text within the <a> tags without the links.

How do I remove just the <a> tags from document object?  Please, no CSS -- I need to get the javascript below working.

Here's the javascript code:

var html = document.getElementById("spacer").innerHTML;
var winprint = window.open("", "", sOption);

winprint.document.write(html);
0
lcor
Asked:
lcor
1 Solution
 
Robert SchuttSoftware EngineerCommented:
try this:
winprint.document.write(html.replace(/<a[^>]*>(.*?)<\/a>/gi,'$1'));

Open in new window

0
 
lcorAuthor Commented:
It works!  Awesome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now