Flash not interacting with Javascripts in browser inside my app - javascript

I have an application which embeds a xulrunner based browser.
I have to load some flash content in it which talks to some javascript to update
the browser title.
The flash content works fine when launched from Firefox but not inside my app. I tried a sample html file which has some javascript and they work fine. It even works when I have the flash content on a server. It is only when I try to run js through flash present on my local machine that I see this problem.
I guess it must have something to do with some security settings in xulrunner.
Could somebody help me figure out what the problem might be?

Check out this answer, it might the solution of your problems.

You can also change the browser title from within the application itself...
import mx.managers.IBrowserManager;
import mx.managers.BrowserManager;
private var bm:IBrowserManager = BrowserManager.getInstance();
bm.init("", "New Browser Title");

Related

Access denied in ActiveX after moving the javascripts in MVC

I have successfully implemented the Smart Card Reader in my project using the HTML and everything is perfectly 100% working but when i transfer all files to my MVC project and run (localhost) I am unable to execute the Initialize function of the Card Reader. Saying that "Access is denied"
In HTML (all functions are working without access denied error)
In MVC
My object
<OBJECT id="EIDAWebComponent" style="border:solid 1px gray"
CLASSID="CLSID:A4B3BB86-4A99-3BAE-B211-DB93E8BA008B"
width="130" height="154"></OBJECT>
Update:
I created a new ASP.Net Web Application (Empty Template) then i copy the whole js and html file. Then set the HTML page as start page. The problem might be in my localhost. When i browse my file in IE using this link C:\Public Data ActiveX\PublicDataActiveX.html the activex is working. But this link http://localhost:28679/PublicDataActiveX.html its not.
The problem might be simply to enable HTTPS in order to have ActiveX to work.
if your stack makes this hard, you can have a proxy on top, like nginx:
http://cnedelcu.blogspot.com.co/2014/10/https-with-nginx-setting-up-ssl.html
You just shared a small portion of code and some pics so it is hard to help this way, but below some tips that you may have to consider:
When you say, it is working in pure html, what does that mean exactly? how do you browse it, double click in an html file and open in the browser as a local file with a path similar to "C:\Folder\File.hml"?
Or do yow browse it with a domain, maybe "localhost/file.html"?
When you say, move to an MVC project, what do you mean? did you put it on a View or you just moved the html and browsed it?
All the questions above are important in order to find where your problem is
If you can browse the .html file in both situations from file system and running your MVC project then the problem is in the MVC itself and it is a coding stuff.
If you cannot browse the same .html exactly the same in file system and running your app, then the problem is not code, it is permissions, Maybe CORS restrictions (by domain), maybe ssl (you said not), maybe you need a key (like google api)
After doing a lot of searching I've found this link
Changing the security settings in IE my ActiveX is now working in localhost.
Open IE >> Tools >> Internet Options >> Security >> Custom Level >>(Enable) Initialize and script ActiveX controls not marked as safe for scripting

Detecting and changing URL of src in Chrome App Webview

Using Chrome://inspect and going to a Chrome App and then source snippets with chrome dev tools, you can use the following code to check the src attribute from a webview and redirect if it has been changed. This may occur when forexample an App is running on a public wifi that auto redirects and a set time period. I want to be able to check for that redirected URL and change it back.
setInterval(function(){
var x = document.getElementsByTagName("webview")[0].getAttribute("src"); //get current domain
//pseudo code - check if x matches a domain...
document.getElementsByTagName("webview")[0].setAttribute("src","Your URL here"); //set webview to domain
},5000);
Where is the best place to put this Javascript code? And does anyone have an example.
What I have tried so far:
inline? if so, then what is the best way to do this as an error message regarding updating the manifest file allowing "unsafe-inline". However, I have read there are security concerns regarding this.
a js file within the app - I tried this but i was unable to find the file in the chrome dev tools to debug and it didn't work. Console.log also would not work. How do you debug JS files from within a Chrome App?
a js file sourced from a server with a nonce? I tried to follow the instructions at http://www.w3.org/TR/2015/CR-CSP2-20150721/#script-src-nonce-usage but couldnt get it to work. Does anyone have an example?
Also, are there any appropriate event listeners that can be used instead? I thought the webview loadRedirect event could be used. If so, where do i put this code?
https://developer.chrome.com/apps/tags/webview#event-loadredirect
Code that interacts with the <webview> element should be running in the same document as that element. So, assuming that page is app.html, you would need to include a script there.
Inline code will not work in a Chrome App, period. You should add a separate local .js file and reference it with a <script> element.
As for inspecting / debugging apps, you need to attach to the app window, not the background/event page. There are 2 helpful tools:
The page chrome://inspect/#apps will list all App windows and you can attach Dev Tools from there.
You can set a Chrome flag to enable context menu with Inspect on Chrome App windows, chrome://flags/#debug-packed-apps, if you expect to do it often.

How to Launch a PDF from a Chrome Packaged App?

My chrome packaged app contains a PDF, and I would like to let the user view it. If I open it in the current frame I get the error "Chrome PDF Viewer is not Allowed".
Frankly, the chrome PDF viewer is pretty awful, so I'd rather let the user view it in their PDF viewer of choice anyway. If I disable the chrome PDF plugin (just as an experiment) and I try to open the PDF using chrome.app.window.open, it "downloads" the PDF, and then the user could open it. But this has two issues:
I can't realistically make the user go to chrome://plugins and do that disable
There isn't any browser window, so the user has no idea the download happened
Any suggestions? Opening PDFs that are embedded in my app is kind of a must-have feature for this app.
I've looked at this extensively, and have come to the conclusion that there's no way to get a Chrome App to open a PDF that's local. I, too, have tried data URIs.
I don't think the issue is the PDF support in the window, as it's still Chrome, or the size of the PDFs. Rather, I think it's just an engineering problem, one that might get solved someday.
As for me, I build the PDF in my Chrome App. Since I can't display it, and there's no server to upload it to, I write it to a file of the user's choosing and let the user deal with it on his/her own.
I've got this working, but whether it is a solution for you depends a lot on your use case. The solution has three parts:
Use pdfjs to do the actual rendering.
To get this running in a packaged app, you'd need to do some violence to the internationalization support. And even after you do that, you'll find that some PDFs refuse to load for no apparent reason whatsoever. So don't bother trying to make pdfjs work in a packaged app. Just:
Put your entire app into a <webview> with a persist partition, and use a HTML5 cache manifest to get all your files available for offline viewing.
Yeah, yeah, I know that cache manifests are not cool anymore. But if you can list all your files for use in a packaged app, then you are doing the one case where cache manifests actually work great.
Then use a packaged app to distribute a tiny wrapper around your page with the webview in it.
You'll also get the benefit that you don't have to rewrite your app to live within the draconian packaged app rules (eval, sync xhr, 2GB limit, etc.).
You can see a working example at m.kaon.com/c/ka (visit with Chrome to get the desktop app; if you visit that with Firefox, you'll get access to a hosted app that is using the same tricks). PDFs are down in the bottom "Why Choose Kaon" section.

Why wont the nude.js html5canvas demo work locally?

Try this nice JavaScript: http://www.patrick-wied.at/static/nudejs/demo/
Warning: slightly NSFW.
It won't work when i open it from my local machine. Either by copying the 3 exact source codes and making the picture locations absolute (or else by downloading https://github.com/pa7/nude.js/archive/master.zip).
I am lost why? it must be a silly/simple reason since the demo page is obviously working and JavaScript only, so why would it make a difference where you store it?
I think this is because of the browser security restrictions. are you opening the html file from the file system, instead of serving it from localhost? or are you referencing resources from another domain that does not have CORS enabled? Debugging with the console should help.

Page reloading and malformed HTML problems in a XULRunner based app

I am writing an application on XULRunner that displays HTML pages from the web:
I have a very simple XUL file with a in which is just a filling the window and loading a local HTML file.
In my HTML, I have an iframe to load content.
What's cool with XULRunner is that I can access the content of the iframe for many things (display page title, images...)
What's not cool at all is that, unlike what I had when my app was running in a browser, I have two big bugs with some pages:
1) Some (many?) pages (like "yahoo.fr" have malformed HTML content, especially for tag where the tag is not closed (the IMG tag without the /> at the end).
==> This does not bother Firefox but in my app, XULRunner does not decode the HTML and thus display the rough HTML source code in the page.
2) On some pages, like, for now, the home of nytimes.com, the login page of bloglines.com and of yahoo.fr, "something" happens in the iframe that causes the src of my tag (that is my app that SHOULD NEVER CHANGE) to change thus closing my app.
==> I guess it may be linked to an attempt to open in another window.
Does anyone have a clue to solve these two problems? Better version of XULRunner (I am using 1.9.1)? XUL options to prevent a page to open in new window? Others?
Thanks for your help,
J.
Rather than a <iframe/>, use a <browser type="content-primary"/>. That will solve your second problem (by letting the system know that the contents of that frame belongs to the web and shouldn't be able to change you).
The first question really depends on how things are being loaded. Are they from http, or from a previously-saved local file? Do you useful mime types and things from the server? Or, if local, what file extension do you end up with?

Categories