@@ -640,6 +640,13 @@ impl<R: Runtime> WebviewBuilder<R> {
640
640
/// This is executed only on the main frame.
641
641
/// If you only want to run it in all frames, use [Self::initialization_script_for_all_frames] instead.
642
642
///
643
+ /// ## Platform-specific
644
+ ///
645
+ /// - **Windows:** scripts are always added to subframes.
646
+ /// - **Android:** When [addDocumentStartJavaScript] is not supported,
647
+ /// we prepend initialization scripts to each HTML head (implementation only supported on custom protocol URLs).
648
+ /// For remote URLs, we use [onPageStarted] which is not guaranteed to run before other scripts.
649
+ ///
643
650
/// # Examples
644
651
///
645
652
#[ cfg_attr(
@@ -669,6 +676,9 @@ fn main() {
669
676
```
670
677
"####
671
678
) ]
679
+ ///
680
+ /// [addDocumentStartJavaScript]: https://developer.android.com/reference/androidx/webkit/WebViewCompat#addDocumentStartJavaScript(android.webkit.WebView,java.lang.String,java.util.Set%3Cjava.lang.String%3E)
681
+ /// [onPageStarted]: https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)
672
682
#[ must_use]
673
683
pub fn initialization_script ( mut self , script : & str ) -> Self {
674
684
self
@@ -687,8 +697,14 @@ fn main() {
687
697
/// Since it runs on all top-level document navigations and also child frame page navigations,
688
698
/// it's recommended to check the `window.location` to guard your script from running on unexpected origins.
689
699
///
690
- /// This is executed on all frames, main frame and also sub frames.
691
- /// If you only want to run it in the main frame, use [Self::initialization_script] instead.
700
+ /// This is executed on all frames (main frame and also sub frames).
701
+ /// If you only want to run the script in the main frame, use [Self::initialization_script] instead.
702
+ ///
703
+ /// ## Platform-specific
704
+ ///
705
+ /// - **Android:** When [addDocumentStartJavaScript] is not supported,
706
+ /// we prepend initialization scripts to each HTML head (implementation only supported on custom protocol URLs).
707
+ /// For remote URLs, we use [onPageStarted] which is not guaranteed to run before other scripts.
692
708
///
693
709
/// # Examples
694
710
///
@@ -719,6 +735,9 @@ fn main() {
719
735
```
720
736
"####
721
737
) ]
738
+ ///
739
+ /// [addDocumentStartJavaScript]: https://developer.android.com/reference/androidx/webkit/WebViewCompat#addDocumentStartJavaScript(android.webkit.WebView,java.lang.String,java.util.Set%3Cjava.lang.String%3E)
740
+ /// [onPageStarted]: https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)
722
741
#[ must_use]
723
742
pub fn initialization_script_for_all_frames ( mut self , script : & str ) -> Self {
724
743
self
0 commit comments