Pen Settings



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


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


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.


Auto Save

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.


                <div class="content">
  <h2 class="content__title">ブラウザの戻るでボタンが出現する</h2>
  <a class="content__link" href="#" onClick="history.back(); return false;">前のページにもどる</a>
  <a class="content__link" href="#about">アバウトへ</a>
  <div id="js-modal" class="modal">
    <a class="modal__close js-modal-close">閉じる</a>


                .content {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 0;

.content__title {
  text-align: center;
  font-weight: bold;
  line-height: 1.5;
  font-size: 24px;

.content__link {
  display: block;
  margin-top: 20px;
  text-align: center;

.modal {
  display: none;
  text-align: center;

.modal__close {
  display: inline-block;
  background: tomato;
  font-size: 18px;
  font-weight: bold;
  padding: 10px 30px;
  color: #fff;
  margin-top: 20px;
  &:hover {
    cursor: pointer;


                let modalState = false;

  window.addEventListener("popstate", (e) => {
    // aタグクリックや進むボタンでの遷移時にも呼ばれるので、モーダルが出てないかつstateがpushedの場合のみモーダルを出す
    if (modalState || e.state !== "pushed")

    // fadeIn/fadeOutはjQueryを使う
    $(".js-modal-close").on("click", ()=> {
      modalState = true;

  const onload = () => {
    window.history.replaceState("pushed", null, null); // 現在のページにstateを付加してpopstateイベントで判定する
    const entries = performance.getEntriesByType("navigation");
    if (entries.some((item) => item.type === "reload")) {
    } else {
      window.history.pushState("pushed", null, null); // 戻るボタンを有効化させるためにヒストリを一つ追加する
  window.addEventListener("load", ()=> {