npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

frames

v0.0.1

Published

Frames allows you to create pre-configured iframes. While providing a common interface to interact with the iframe's contents.

Downloads

92

Readme

Frames

Frames is a simple helper function that creates a pre-configured iframe and appends it to the given DOM element while providing a nice API for interacting with the iframe.

This module assumes that it's used by a Node.js compatible module system.

Installation

npm install frames --save

Usage

The reason why we've decided to go with methods that exposes the properties vs just exposing a document and window property is that these values and their references change when you remove and add the iframe back in the DOM.

There are 2 requirement arguments when you create a new iframe:

  1. The parentNode where the iframe should be appended to.
  2. A unique id for the iframe. This id will also be used for the name attribute.

The third argument is the options argument which can be used to configure:

  • visible: This hides the iframe by giving it a display none and positions it outside the document using absolute positioning. Defaults to true
  • sandbox: These values are used to set the sandbox attribute on the iframe. It defaults to: [allow-pointer-loc, allow-same-origin, allow-scripts, allow, popups, allow-forms]

The module exposed as single function, so it can be used like this:

'use strict';

var iframe = require('frames');

//
// Create a new iframe and add which will be added to the `document.body`
//
var frame = iframe(document.body, 'foo_'+ Date.now());

The following methods are exposed on the returned object:

frame.document()

The document method returns the document of the created iframe. This can be used to inject elements in the HTML of the iframe.

frame.window()

The window method can be used to return the window or global of the iframe. This allows you to introduce new variables in the iframe as well as see which globals are exposed within the iframe.

frame.add()

Adds the iframe element to initially supplied parentNode. It will only add the element if it wasn't already in the DOM.

frame.remove()

Remove the iframe element from the parentNode. This causes the iframe to trigger an unload event in the browsers that support it. (Basically every browser except older Opera browsers).

frame.attached()

Check if the iframe has been added to the parentNode.

frame.frame

Reference to the created DOM node, which can be used for all other kinds of interactions.

License

MIT