On Sunday, February 9, 2020 at 7:00:35 PM UTC-8, TonyM wrote:
>
> I understood that a tiddler containing
> <script type="text/javascript">
> document.getElementById('forum_embed').src =
> '
> https://groups.google.com/forum/embed/?place=forum/tiddlywiki-by-psat'
> + '&showsearch=true&showpopout=true&showtabs=false'
> + '&parenturl=' + encodeURIComponent(window.location.href);
> </script>
> tagged $:/tags/RawMarkup would place this inside the header and register
> the javascript
>
Then visiting a tiddler containing
> <iframe id="forum_embed"
> src="javascript:void(0)"
> scrolling="no"
> frameborder="0"
> width="900"
> height="700">
> </iframe>
> Would embed the forum, unfortunately it is an empty window
>
The code that is loaded via $:/tags/RawMarkup does not define a function
that can be invoked later. Rather, it directly runs the code as soon as
the document is loaded. However, the tiddler containing the iframe is not
rendered until that tiddler is displayed. As such, when the code is loaded
and run, the iframe it refers to doesn't exist yet, so
the document.getElementById('forum_embed') returns a null, and nothing is
actually performed.
Is there any guidance you can give for me to make this instance work, and
> ideally any such examples so I may document it?
>
In this particular use-case, it might be possible to bypass the code
entirely, and just move the target URL directly into the "src" attribute of
the iframe declaration. One issue with this is that the URL uses
javascript to encode and append the "parenturl" parameter to the source
URL. However, as you know, you can't directly invoke javascript code
within a tiddler, so we need to work around that using TiddlyWiki syntax.
Fortunately, the value of "window.location.href" *is* available in
TiddlyWiki by reference to the $:/info/url/full tiddler, which is
initialized during startup.
Try this (paste into a tiddler):
<$vars parentURL={{{ [title{$:/info/url/full}encodeuri[]] }}}>
<$vars srcURL={{{
[title[https://groups.google.com/forum/embed/?place=forum/tiddlywiki&showsearch=true&showpopout=true&showtabs=false&parenturl=]addsuffix
<parentURL>] }}}>
<iframe id="forum_embed"
src=<<srcURL>>
scrolling="no"
frameborder="0"
width="100%"
height="700">
</iframe>
</$vars>
</$vars>
Notes:
* I changed the "place" parameter from "forum/tiddlywiki-by-psat" to just
"forum/tiddlywiki"... otherwise it gave me a "permission error"
* I changed the iframe width to 100% so it uses the full width of the
tiddler display area
... and I tested it on http://www.tiddlywiki.com... and it seems to work!
enjoy,
-e
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/c6b97578-22b0-4dc8-99a6-0ddca0e5e388%40googlegroups.com.