mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 19:32:07 +00:00
Open external link in a new tab when embedded in an iframe (#2846)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'gitbook': patch
|
||||
---
|
||||
|
||||
Fix opening external links when the GitBook page is embedded in an iframe
|
||||
@@ -47,6 +47,13 @@ export const Link = React.forwardRef(function Link(
|
||||
});
|
||||
}
|
||||
|
||||
// When the page is embedded in an iframe, for security reasons other urls cannot be opened.
|
||||
// In this case, we open the link in a new tab.
|
||||
if (isExternal && window.self !== window.top) {
|
||||
event.preventDefault();
|
||||
window.open(href, '_blank');
|
||||
}
|
||||
|
||||
domProps.onClick?.(event);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user