[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Printer Friendly Javascript Remove Links

Posted on 2012-08-10
2
Medium Priority
?
555 Views
Last Modified: 2012-08-10
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
Comment
Question by:lcor
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 38282047
try this:
winprint.document.write(html.replace(/<a[^>]*>(.*?)<\/a>/gi,'$1'));

Open in new window

0
 

Author Closing Comment

by:lcor
ID: 38282348
It works!  Awesome!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month18 days, 22 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question