[Plugin] Webview for browser (using iframe) #3687
-
As per #2515 comment, webview note doesn't work in browser. So i've made an alternative using iframe. Source codeHTML. Set note type as HTML. <iframe class="my-iframe" frameborder="0" style="overflow:hidden;height:100%;width:100%" width="100%" height="100%"></iframe>
<h1 class="my-hint"></h1>
<style>
div:has(> .my-iframe),
.note-detail:has(.my-iframe),
.note-detail-render:has(.my-iframe),
.note-detail-render-content:has(.my-iframe) {
height: 100%;
}
</style> Javascript. Set note type as JS frontend. Save this note as child note under the HTML note. const ATTR_NAME = "webSrc"
let note = api.getActiveContextNote()
let frame = api.$container.find(".my-iframe")
let hint = api.$container.find(".my-hint")
console.log(note.type, frame, hint)
if (note.type === "render" && frame.length === 1) {
let webSrc = note.getAttributeValue("label", ATTR_NAME)
console.log(webSrc)
if (webSrc != null) {
frame.attr("src", webSrc)
} else {
frame.hide()
hint.text("To load a webpage, set webSrc label to a URL")
}
} else {
hint.text("Cannot find the iframe element")
} How to useAfter saving the source code,
Limitation
|
Beta Was this translation helpful? Give feedback.
Answered by
eliandoran
Feb 17, 2025
Replies: 1 comment
-
Just added support for using |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ReinforceZwei
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just added support for using
iframe
for webview in TriliumNext as well.