tuarua / WebViewANE

WebView Adobe Air Native Extension for macOS 10.10+, Windows Desktop, iOS 9.0+ and Android 19+. This ANE provides access to a more modern webview from AIR.
Apache License 2.0
183 stars 53 forks source link

Local file with Get Params #219

Closed jasonJamEther closed 5 years ago

jasonJamEther commented 5 years ago

I am using windows edge to load local html sites. Everything works well until I try adding some GET parameters to my url (?param1=1). This doesn't appear to be allowed. Is there another way to handle this?

tuarua commented 5 years ago

load local html sites.

This is too vague. Please explain which method(s) you are calling.

This doesn't appear to be allowed.

Explain "allowed" What happens, does it strip off the query string?

It's better to provide full reproducible steps with expected and actual result.

It's likely that whatever you are trying to do is not permitted by the MS WebView.

jasonJamEther commented 5 years ago

I am sorry that I didn't explain better. I simply want to load a local file with some url parameters. file://myfile.html?myparam=1

for example - windowsWebView.loadFileURL(localFile.nativePath + "?customSlideOrder=5",localFile.parent.nativePath);

Trying to do this, the webview just loads an empty white page.

If I have a local file without any url parameters it works great. But even if I click a link inside that webpage that then points to another local file url <a href="example.html?test=1">test</a> that has GET variables, that link won't work and instead the page remains as if nothing had been clicked.

I am hoping there is a simple way around this or a simple call that I am missing. Thank you for your time on this great ANE.

tuarua commented 5 years ago

I'm afraid querystring params won't work in the Edge version for local files (and result in an error too). Edge uses a file stream to load in files. It sees the ?test=1 as part of the file name and then says it can't find that file.

There is no way to change this. Edge component is less rich than Chromium. The only solution is to either use Chrome WebView or run your local site on a locally running webserver. You can package nginx.exe and start it using NativeProcoess. https://nginx.org/en/docs/windows.html

Loading local files via file calls should not be used for complex websites as you will eventually hit problems such as CORS.

[trace] ms-local-stream://Microsoft.Win32WebViewHost_cw5n1h2txyewy_4c6f63616c436f6e74656e74/localTest.html?param=1 [trace] 18 [trace] UnexpectedStatusCode

tuarua commented 5 years ago

You could try setting localStorage or a cookie via webView.evaluateJavascript to save the variable, that could get round it.

jasonJamEther commented 5 years ago

Thank you for your help. I will try some of your recommended solutions.