iframe.html 1.2 KB

123456789101112131415161718192021
  1. {{ $src := .Get "src" | }}
  2. {{ $width := .Get "width" | default "100%" }}
  3. {{ $tryautoheight := .Get "tryautoheight" | default true }}
  4. {{ $style := .Get "style" | default "min-height:98vh; border:none;" }}
  5. {{ $sandbox := .Get "sandbox" | default false }}
  6. {{ $name := .Get "name" | default "iframe-name" }}
  7. {{ $id := .Get "id" | default "iframe-id" }}
  8. {{ $class := .Get "class" }}
  9. {{ $sub := .Get "sub" | default "Your browser can not display embedded frames. You can access the embedded page via the following link:" }}
  10. {{ with $src }}
  11. {{ if $tryautoheight }}
  12. <script type="text/javascript">
  13. function resizeIframe(iframe) {
  14. iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
  15. }
  16. </script>
  17. {{ end }}
  18. <iframe id="{{ $id }}"{{ with $class }} class="{{ $class }}"{{ end }} src="{{ $src }}" width="{{ $width }}" name="{{ $name }}"{{ with $style }} style="{{ $style | safeCSS }}"{{ end }}{{ if $tryautoheight }} onload="resizeIframe(this)"{{ end }} referrerpolicy="no-referrer"{{ if (eq $sandbox false)}}{{ else if (eq $sandbox true) }} sandbox{{ else }} sandbox="{{ $sandbox }}"{{ end }}>
  19. <p>{{ $sub }} <a href="{{ $src }}">{{ $src }}</a></p>
  20. </iframe>
  21. {{ end }}