Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-add-hash-to-parent

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-add-hash-to-parent

if the book is contained in another window with a iframe tag, the parent window will automatically refresh hash key in the address bar

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

使用

当gitbook做为其它页面的子页面嵌入时,在gitbook所在的iframe内切换文章时,并不会在父页面的url中反映出来,这将导致不能复制文章的url时总是会跳到这个gitbook的首页,极为不方便。

此插件安装后,会在切换文章的时候,利用history.pushState,将当前url作为父页面的hashkey追加到父页面url的未尾,如:

gitbook页面url为:

http://localhost/xxx-gitbook/pageA.html

则其父窗口的url会显示为:

http://localhost/path/to/page.html#xxx-gitbook/pageA.html

当然,你还需要在父容器的js代码里添加处理hashkey的部分的代码,将iframe跳转到对应的页面。

比如:

$(function() {
    location.hash && $('#iframe-id').attr('src', location.hash.substring(1));
});

FAQs

Package last updated on 11 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc