Consider an Electron application with a GUI like this:
<body>
<div><!-- anything here --></div>
<iframe id="frame" src="document.html"></iframe>
</body>
The iframe element loads a local file from the app's root directory.
When I start the app (npm start), everything works fine. But if I use the "Force Reload" option to see the changes I made without restarting the app, I suddenly bump into a cross origin problem.
The symptoms:
1) The iframe is listening for changes in the app's localStorage.
let frame = document.getElementById("frame");
frame.contentWindow.addEventListener("storage", function(e) {
// do something
});
After "Force Reload", I get the following error: Uncaught DOMException: Blocked a frame with origin "file://" from accessing a cross-origin frame.
2) If I try to access the contentDocument of the iframe, I get null.
console.log(frame.contentDocument); // -> null
The strange thing is, none of these happen when I start the app, only after I reload it.
Any ideas? Am I doing something wrong, or is it a bug in the latest Electron (5.0.7)? I had no problem with older versions, but I don't know if it's an intended change or a bug, or my mistake.
Related
I am experiencing something in production which isn't reproducible locally.
The Link from nextjs (version 12.3.x) works well in development and when running the build in production mode locally, meaning that the navigation happens without a full page reload. But when deployed with terraform, all Link components are causing a full page reload. Everything else works as expected.
I have a mixture of Link children across the application, sometime it's a, but other times it's a button or simply a div or span. In every case, the full page refresh happens. That's why I suspect it must be something related with the configuration rather than the Link usage, however I am not sure where to start debugging and I am looking for a hint in the right direction.
Back with an answer to this. In my case, nothing was wrong with the Link components itself, nor with the build. The problem was with a path rewrite in our terraform configuration (it was rewriting everything in /_next/*).
It appears that getServerSideProps fetches JSON files which will be used to render the page Their paths were being re-written and causing a 403 error, which made the page reload instead of allowing me to navigate seamlessly as I am used to with next.
This problem was very specific to my configuration, but my general recommendation is to check whether you are rewriting any path of the json files created by next at navigation, in case you are experiencing the same problem only on staging/production.
Problem:
I use CEFSharp to serve local content in a C# application.
In some cases I've got several iframes that should load different local URLs based on user actions.
I load content in those iframes using the Iframe.LoadUrl method. The URL is using the file schema.
In runtime, the application does not load the new url for the iframe until I open the devtools. When I do that, the iframe's contents are loaded perfectly and quickly.
This only happens once per iframe: After opening devtools, I can execute the same code and the iframe's contents are updated accordingly. I'm guessing the iframe's state is wrong somehow, but so far I haven't found any differences before/after opening devtools.
Context:
This application was running OK in CEFSharp 85.3. The library's version was upgraded to 101.0.
The code I'm working on is a plugin, and the initialization is managed by the main app, so I have little flexibility there. I could request changes if reasonable though.
Has anyone seen something like this before?
I've found a workaround for now, it seems to be working fine:
instead of doing:
frame.loadURL(url)
I'm using:
frame.Parent.ExecuteJavaScriptAsync("document.getElementById('" + frame.Name + "').src = '" + url + "'", "file:///");
I'm not really happy with my solution, but it seems to be working for now in my case.
I am developing an iOS app that mainly loads my web pages in WKWebView.
Things were fine so far before I start facing a weird issue with one of the CSS file not loading.
The font-awesome.css file is not loading, generally it gets loaded on the very first page call. In my knowledge nothing has been changed on the server side that could affect loading of font-awesome.css file.
I am intercepting request by implementing following function in iOS app code. But for the first request I just do decisionHandler(.allow) because I don't want any interception for the first request.
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: #escaping (WKNavigationActionPolicy) -> Swift.Void) {
// For the first request it will go as is
decisionHandler(.allow)
}
Once the first page gets loaded on WKWebView the font-awesome.css file didn't get loaded hence some font icons are shown as squares on the page.
After spending some time on this issue I tried to put a delay on calling decisionHandler(.allow) as follows and then it starts loading the font-awesome.css file:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.150) {
// I just added a delay of 150 ms and it starts loading the css file.
decisionHandler(.allow)
}
For me currently its very confusing to figure out the relation between putting a delay and loading of the css file.
I need suggestion on this behavior why its happening or is there anything else due to which this is happening and I am just doing a work around by putting a delay.
Some more updates:
I have an Android app also that is loading same web pages in WebView and that is working fine.
I check the IIS logs by sending the request with and without putting the delay. With the delay I an clearly see in IIS logs that it loads the font awesome as follows, but in without delay I don't see this entry in IIS logs:
2020-11-23 13:44:36 10.100.2.72 GET
/Content/fonts/fontawesome-webfont.woff2 v=4.5.0 80 - 10.100.0.111
....
I have run meteor in my applications 100 times, and my apps always render to localhost:3000. right now, though, on one specific app, my browser is blank. Ive hosted it locally before and I can host other applications. additionally, there are no console/terminal errors.
When I view page source, it's blank, but when I inspect elements, it's my code...
I pulled down a version of the project that I know worked on localhost, and I get the exact same thing.
What could be happening?
Try this, It worked for me:
cd to-your-app-dir
meteor npm install
meteor
Ensure that you have a route set for localhost:3000/.
See flow-router or iron-router.
Also double check what your app does during the onCreated() event of your template at localhost:3000/.
I've seen this SO posting about using iframe's and doing postMessage: Metro App and iFrame cookie. I'm trying to do something very similar in Win8 Release Preview with an HTML/JS Metro application, but it seems rather impossible to replicate the behavior in that solution.
I have a simple frame stored in a remote location as:
<!DOCTYPE html>
<html>
<body>
<script>
window.onmessage = function(e) {
alert("Hello world");
debugger;
};
</script>
</body>
</html>
In my default.html I have a div that contains the iframe as follows:
<div id="container">
<iframe id="frame" src="https://dl.dropbox.com/u/75275447/win8Frame.html"></iframe>
</div>
I have an arbitrary button that executes a postMessage on #frame and would in a normal Html site trigger the remote frames onmessage, but instead I can look at the error list in VS and see:
APPHOST9613: The app couldn’t navigate to
https://dl.dropbox.com/u/75275447/win8Frame.html because of this
error: RESOURCE_NOT_FOUND.
I have tried looking into any manifest that might allow me to achieve this and enabled:
Home or Work Networking
Internet (Client & Server)
Internet (Client)
To no avail... I have also tried having a frame (local to the application) loaded into the web contenxt (via ms-wwa-web://) that contains a div that hosts the remote iframe and chain up onmessage to forward a postMessage to the remote iframe, but again I see another error:
APPHOST9624: The app can’t use script to load the
ms-wwa-web://frame.html/ url because the url launches another app.
Only direct user interaction can launch another app.
I'm beginning to think this is an impossible task.
The one piece of information I leave out as I considered it unrelated to this issue was an error found in the javascript console related to using Jquery that I found a solution in another SO post. Clearing up that issue now allows the app to load the remote iframe and I can press the button and see the message reach the remote iframe's javascript (in my case I see alert() being undefined, but I was just trying to prove that I could load and execute remote code).
I guess the moral of the story is clear up related javascript console errors...