Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
  <h4>Generate mailto: links for Intercom</h4>
  <div class="form-group">
    <label for="subject">Subject</label>
    <input type="text" class="form-control" id="subject" aria-describedby="emailHelp" placeholder="Enter subject">
    <small id="emailHelp" class="form-text text-muted">Leave blank for no subject.</small>
  </div>

  <div class="form-group">
    <label for="to">Email to send to</label>
    <input type="email" class="form-control" id="to" aria-describedby="emailHelp" placeholder="Enter email">
    <small id="emailHelp" class="form-text text-muted">Leave blank if unknown.</small>
  </div>

  <div class="form-group">
    <label for="cc">Email to CC</label>
    <input type="email" class="form-control" id="cc" aria-describedby="emailHelp" placeholder="Enter email">
    <small id="emailHelp" class="form-text text-muted">Leave blank for no cc.</small>
  </div>

<div class="form-group">
    <label for="text">Email content (you can use custom tags)</label>
    <textarea class="form-control" id="text" rows="8">Hey there,

I need your help installing Upscope (a screen sharing software we need) on our website.
You can find the instructions here: https://xyz.com/install/{{ company.remote_company_id }}

Feel free to ask if you have any questions.

{{ first_name }}</textarea>
  </div>
  <button class="btn btn-primary" onClick="insertLink()">Generate link</button>
  <button class="btn btn-secondary" onClick="tryLink()">Try it yourself</button>

<br />
<br />
  <div class="form-group">
    <label for="link">Link</label>
    <input type="text" class="form-control" id="link" disabled>
  </div>
              
            
!

CSS

              
                
              
            
!

JS

              
                function fixedEncodeURIComponent(str) {
  return encodeURIComponent(str).replace(/[!'()*"]/g, function(c) {
    return '%' + c.charCodeAt(0).toString(16);
  });
}

function getLink(encodeEverything) {
  var subject = document.getElementById('subject').value,
      to = document.getElementById('to').value || '',
      cc = document.getElementById('cc').value,
      text = document.getElementById('text').value;
  encodeEverything = encodeEverything || false;
  var link = 'mailto:' + to + '?';
  if(subject)
     link += 'subject=' + fixedEncodeURIComponent(subject) + '&';
  
  if(cc)
     link += 'cc=' + cc + '&';
  
  link += 'body=';
  
  link += fixedEncodeURIComponent(text);
  
  if(!encodeEverything){
    link = link.split(encodeURIComponent('{{ ')).join('{{ ')
    .split(encodeURIComponent(' }}')).join(' }}')
    .split(encodeURIComponent('{{')).join('{{')
    .split(encodeURIComponent('}}')).join('}}');
  }
  
  return link;
}

function insertLink() {
  var link = getLink();
  document.getElementById('link').value = link;
}

function tryLink() {
  window.open(getLink(true));
}
              
            
!
999px

Console