I'm looking to access the window.location in an EM_JS method in order to call a JavaScript method from C++.
My attempted approach was:
EM_JS(const char*, getlocation, (), {
let location = window.location;
let length = lengthBytesUTF8(location) + 1;
let str = _malloc(length);
stringToUTF8(location, str, length);
return str;
});
However, I'm encountering this error:
ReferenceError: window is not defined
Is there an alternative method to retrieve window.location in C++ code compiled with Emscripten without passing the value through the C++ API using ccall or cwrap?