Skip to main content
100%

D3 PJAX (& execute JS loaded through the d3.html() request as well)

✓ Published0🌍 Public
GGerHobbelt
Last edited Sep 10, 2012
Created on Apr 27, 2012

This example demonstrates a PJAX-style navigation pattern using D3.js, where clicking menu links asynchronously loads page content into a central area without full page reloads. The demo includes three pages (Anteater, Baobao, Cuttlefish), each displaying an article and a script-generated timestamp. The `d3.html()` API fetches the requested HTML fragment, while the `pjax` function handles click events, updates the browser history via `history.pushState`, and re-applies links after each load. It also executes any JavaScript found in the loaded fragment, using a custom `evalScript` function and a `d3.selection.prototype.replaceWtext` hack to safely replace `document.write` calls with text content.

AI-generated description

Similar vizzes