Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 905929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:18:11+00:00 2026-05-15T16:18:11+00:00

Currently I am writing a system for a user that on filling in a

  • 0

Currently I am writing a system for a user that on filling in a form it creates a template for a HTML email that will be able to use with their CRM system, the issue is that you user is a bit docile and for the live of them cannot understand how to view the source of the page so they can copy and paste the template code into their CRM, what I am wanting is there to be able to have a link/button that user can click that will show the source code in a window, I am in now way a javascript developer so any tips, hints examples would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:18:11+00:00Added an answer on May 15, 2026 at 4:18 pm

    Well you probably want to do something like this: grab the “innerHTML” of the element containing your template HTML (or whatever it is). Then open a new window and drop the HTML into it, surrounded by a <pre> block. You’ll also want to replace all the important markup characters with appropriate HTML entities, and probably replace newlines with <br> elements.

    It’d probably be close to this (but it’s not tested):

    var html = document.getElementById('whatever').innerHTML
      .replace(/&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
      .replace(/\r?\n/g, '<br>');
    
    var w = window.open('', 'SourceWindow', 'height=500,width=600');
    var d = w.document.open();
    d.write('<html><body><pre>' + html + '</pre></body></html>');
    d.close();
    

    edit — if you want to strip script blocks, you could add this “replace” call to the series above:

    .replace(/<\s*script[^>]*>.*?<\/\s*script[^>]*>/g, '')
    

    That’s a little shaky because in general trying to recognize HTML with a regular expression is not really possible. However, since script tags don’t really contain markup and definitely end with the next closing script tag, it’s less odious than the general case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a Powershell script that's used to select a user from Active
Im currently developing a system where the user will end up having large arrays(
I am currently writing a program which takes user input and creates rows of
I'm currently writing an application in ASP.NET/C#, where the user needs to be able
I'm writing a program that asks the user for their birthdate and then calculates
I'm currently in the throes of writing a system based on subdividing space (it's
I am currently re-writing my functions script (PHP) for my login system. Is the
I am currently writing a program using Weka that builds a model (using one
I'm currently writing a simple app that performs a series of requests to the
I'm currently writing a function what would create a zip file, which will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.