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

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.

HTML

              
                <!-- 
Every time the page is reloaded, a different link appears at random!
If you change the id of this div, be sure to change it in the JS too! -->
<p>Every time the page is reloaded, a new set of links appears from a list in the JS. </p>
<p>The way I built this, no duplicates will appear.</p>
<div id="randomPages"></div>
              
            
!

CSS

              
                body {
  font-family:'sans-serif', sans-serif;
}
              
            
!

JS

              
                // Here is where you list your pages! You can use either ABSOLUTE or RELATIVE links. If you're not sure the difference, I recommend using full links starting with 'https://'

// here's where we list the pages. The first item is the URL and the second item is the title.
var webPages = [
            ["https://yesterweb.org/community/", "The Yesterweb Community"],
            ["https://yesterweb.org/link-directory/", "Link Directory"],
            ["https://yesterweb.org/zine/", "The Yesterweb Zine"],
            ["https://yesterweb.org/webring/", "The Yesterweb Webring"],
            ["https://yesterweb.org/radio/", "The Yesterweb Radio"],
            ["https://yesterweb.org/manifesto/", "Internet Manifestos"],
            ["https://yesterweb.org/bb/", "Bulletin Board"],
            ["https://yesterweb.org/community/gemini.html", "Gemini"],
            ["https://yesterweb.org/community/cafe/", "Yesterweb Cafe"],
            ["https://yesterweb.org/mascots/", "Yesterweb Mascots"],
            ["https://yesterweb.org/graphics/buttons.html", "88x31 Buttons"]
            ["https://yesterweb.org/no-to-web3/", "Keep the Web Free, Say No to Web3"]
        ]

// this function shuffles the array (reorder the items randomly)
function shuffle(webPages) {
	let currentIndex = webPages.length, randomIndex;

	// while there are items left to shuffle...
	while (currentIndex != 0) {
	// pick a remaining element...
	randomIndex = Math.floor(Math.random() * currentIndex);

	// decrease
	currentIndex--;

	// swap with current element
	[webPages[currentIndex], webPages[randomIndex]] = [webPages[randomIndex], webPages[currentIndex]];
	}
	return webPages;
}

function displayLinks(num) {
  shuffle(webPages);
  
  for (let i = 0; i < num; i++) {
    var link = "<a href='" + webPages[i][0] + "'>" + webPages[i][1] + "</a><br>";
    document.getElementById('randomPages').innerHTML += link;
   }
}

/* below is the code that executes our program 
you can change the '5' number to anything 
as long as it's lower than the total number of links in your array. */

/* it is guaranteed to have no duplicates! */ 
document.addEventListener("DOMContentLoaded", function() {
  displayLinks(5);
});
              
            
!
999px

Console