[Question] WebAssembly Dynamically URL Change
-
Hi ,
I found out that webassembly runs on canvas element , it is just a drawing in a browser not actually an html page,you know that clicking buttons on canvas does not actually browsing pages , it is just changing the canvas drawing to another drawing , okay given the fact that this is a canvas UI, for a regular user that likes to bookmark everything informative pages , this is not helpful because even they bookmark the page it will run on the first page not the page they want.
for this i think we can solve this by changing the URL (for example button1 = http://my.url/app?myquery=page1 , then button2 = http://my.url/app?myquery=app2) when a user clicks the button on the canvas UI the URL change dynamically , and then once the user click refresh button from the browser ,
the QML or C++ will check the URL (for example , http://my.url/app?myquery=page2 ) and then start the page into page2 instead of page1is this even possible ?
Thanks
-
@jhayar said in [Question] WebAssembly Dynamically URL Change:
@Renio thanks for the reply , what is mdi area ?
maybe we can solve this if i can add JS file into main html file?
The html file is generated in compiling time. You can modify this file, but next compiling you lost your changes
then if there's a way that QML can communicate to a JS code ? and JS code to QML ? would you know ?
thanksI don't know... sorry
-
Qt WebAssembly uses emscripten, so technically you can call any Javascript from your C++ code using emscripten API. See https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#interacting-with-code-call-javascript-from-native. Maybe that will help you change the query in the URL?
At least the opposite - reading URL query from C++ code is possible. That I have tested.
#include <emscripten/val.h> ... emscripten::val location = emscripten::val::global("location"); auto search = location["search"].as<std::string>();
For cross-platform code wrap the emscripten stuff in
#ifdef Q_OS_WASM
.