123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <p>Made this so I could search a user database from anywhere on a site I manage with much less fuss.</p>
<p>Use this as your bookmark location. Of course, change the .js file link to wherever you store yours.</p>
<p>This demo will not work.</p>
<code>
javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://www.xyz.com/yourJavaScriptFile.js';})();
</code>
            
          
!
            
              /* ###

There are two JS files. 

*/

/* ### JS File 1 ### */

// Make a variable that holds a new <iframe> element. 
var ifrm = document.createElement("IFRAME"); 

// Choose the page you want to load into the <iframe>
ifrm.setAttribute("src", "http://www.monkeyseatkoalas.com"); 

// A bit of styling of the iframe. Lay it out as you wish. I choose width of 100% because I want it to operate like a second window.
ifrm.style.width = 100+"%"; 
ifrm.style.height = 600+"px"; 

// Attach the new <iframe> to the body of the page we're on. Caveats: <iframe> and goofing about with it only works when you keep everything in one domain. 
document.body.appendChild(ifrm);

// Now we have an iframe on our document. It has a position of [0]. So let's now do something odd -- let's attach ANOTHER JavaScript file to this new iframe page. Why? Because that makes it easy to manipulate that page  with a fresh JS file. Here you go: 
frames[0].document.body.appendChild(frames[0].document.createElement('script')).src='http://www.bigstoragethingy.com/yourOtherJSTrickeryFile.js';


/* ######

#########
########## JS File 2 ### 

#### */ 

// We don't want to do anything until the whole beast is loaded. Otherwise, we might not be able to access somthing we want, or calculations we do based upon elements in the page might not work. Still, it's your call. You might be able to run this at an earlier stage in the load. 
window.onload = function () {

  // Looky there at that .forms. w00t! Handy! In the brackets, we have the form's ID. If it doesn't have one, go ahead and give it one, and make your life easier. How? Hmm. I think document.forms[numberOfFormElementOnThePage].setAttribute('id', 'mySpecialCupcakeFormCheeseName');
  var getDatForm = document.forms["IDofYourForm"];

  // Well, we need to find and store the box we want to populate with something. So we just use our form, nicely stuck in a variable, and do that super-handy elements[x] to it. In a form, this refers to the <input> tag. So the first <input> tag in your form will be yourForm.elements[0].
  var getDatSearchBox = getDatForm.elements[1];

  // Gettin' all interactivey here. Yep, ask your friendly Web user to provide something he/she wants to find. Stick it in a variable.
  var nameToFind = prompt('Word to hunt for? Name? Ice cream? Doggy?');

  // Update your search box with that text. 
  getDatSearchBox.value=nameToFind;

  // BOOM! Submit your form. 
  document.forms["users_search"].submit();
};
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console