-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved iframe handling: headers and footers are hidden when '?for_i…
…frame=true' is in the link parameters
- Loading branch information
Michael Greenburg
committed
Feb 7, 2024
1 parent
3160411
commit 9c06c64
Showing
3 changed files
with
16 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
// Adds `target="_top" to every link on the page so that the page can be used by iframes if 'linktarget=top' is in the link parameters; for use with Canvas | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
var UrlParams = new URLSearchParams(window.location.search); | ||
if (UrlParams.get('linktarget') === 'top') { | ||
const UrlParams = new URLSearchParams(window.location.search); | ||
if (UrlParams.get('for_iframe') === 'true') { | ||
// Add target="_top" to links | ||
var links = document.getElementsByTagName('a'); | ||
for(var i=0; i<links.length; i++) { | ||
if (!links[i].hasAttribute('target')) { | ||
links[i].target = '_top'; | ||
} | ||
} | ||
// Hide header and footer | ||
document.body.classList.add('hide-header-and-footer') | ||
} | ||
}); | ||
}); |