Basically I want to access window.location in a EM_JS method to call this javascript method from c++.
I tried like this
EM_JS(const char*, getlocation, (), {
let location = window.location;
let length = lengthBytesUTF8(location) + 1;
let str = _malloc(length);
stringToUTF8(location, str, length);
return str;
});
But getting
ReferenceError: window is not defined
Or is there any other way to get window.location in c++ code compiled with emscripten? But I don't want passing the value of window.location using js to c++ api using ccall or cwrap.