-
How can I call the external when running in the browser? e.g. window.location = 'https://www.google.com"; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Before: Dyn.global["document"]["location"] = "https://google.com/" After this PR you can also run JS code: You will be able to do in the // alterntaively: Platform.isJs
if (JSEval.available) {
JSEval("window.location = url;", "url" to "https://www.google.com/")
} In the meantime, you can just use the You can read more about it here: https://kotlinlang.org/docs/multiplatform-connect-to-apis.html You can also check the PR #1086 to see how it was implemented, since it should be the same in your project. |
Beta Was this translation helpful? Give feedback.
Before:
After this PR you can also run JS code:
#1086
You will be able to do in the
commonMain
sourceset:In the meantime, you can just use the
expect
/actual
approach. You create anexpect
function in the commonMain sourceset, and then implement it in the JS source set, and create a dummy implementation on the other targets/source sets.You can read more about it here: https://kotlinlang.org/docs/multiplatform-connect-to-apis.html
You can also check the PR #1086 to see how it was implemented, since it sh…