From 03dcfd05b631a7ec55d7022c868603b492638e41 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Thu, 24 Jan 2019 14:03:42 -0500 Subject: [PATCH] support anchors in url when iframed --- _layouts/spec.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_layouts/spec.html b/_layouts/spec.html index f92c5d9..4ade375 100644 --- a/_layouts/spec.html +++ b/_layouts/spec.html @@ -65,7 +65,12 @@ headingSelector: 'h2, h3, h4, h5, h6', collapseDepth: 3, positionFixedSelector: ".toc", - onClick: (e) => { history.replaceState(null,null,e.target.href); }, // put anchor into url on toc link click + onClick: (e) => { // put anchor into url on toc link click, and send to parent window if this is iframed + history.replaceState(null,null,e.target.href); + if (window.parent) { + window.parent.postMessage(e.target.href.substr(e.target.href.lastIndexOf('#')+1), "*"); + } + }, }; tocbot.init(options);