Prevent built-in prompts in xul - xul

I have an application that loads a web page in the browser and saves it to custom local folder (images, html, css). In the process the "src" attribute of images (in html) and "background-url" property (in css) need to be changed to reflect the locally saved files rather than the original ones. This generates extra web traffic as changing them forces the browser to download the files from modified locations (the browser does this by resolving the uri of the page with the value of element's "src" attribute - the same for "background-url" property ) and as a result, it generates lots of 404 Not Found requests.
I'm using nsIIOService interface to go offline before saving the page (the page is fully loaded and all network activity so far has been stopped) and then back online after the saving is complete. But then the browser displays an alert box "This document cannot be displayed while offline. To go online, uncheck Work Offline from the File menu." whenever I try to change the aforementioned attributes/properties.
Is there any way to prevent such message from appearing or to make the browser not validate the images because of modified "src" values?
I tried to use DOMWillOpenModalDialog on both the browser and the xul application window, but it seems it's of no use - the dialog still appears. The application is not an user application, so it's difficult when such "built-in" messages appear.

Use preventDefault to stop the modal dialog:
document.getElementById(‘content’).contentWindow.addEventListener(‘DOMWillOpenModalDialog’,function(e){ e.preventDefault(); }, true);
As an alternative, try using disablePrivilege, sandbox, redefining the prompt service, or overriding window.alert.

Related

How to remove hashtag(#) from vue-router URL?

I want remove hashtag(#) from urls, but also i need to save no-reload mode. Can i do that?
I have: page.com/#/home
I want: page.com/home
I tried mode: 'history', but page reloads with it.
UPD: Is it possible to create SPA app without page reloading and with normal URLs?
When activating the history mode, you need to first configure your server according to the documentation. The reason for that is, that the history mode just changes the URL of the current page. When the user actually reloads the page, he'll get a 404 error, because the requested URL is not actually there. Reconfiguring the server to serve always the main index.html of your SPA resolves this issue.
When using a # in the URL (no history mode), the browser tries to navigate to the element with the ID, which was given after the # (within the same document). This was the original behavior of the fragment identifier. Therefore, if you add a link to your HTML with such a fragment identifier, the browser won't reload the page but actually look for the ID inside the document. The vue-router watches this change and routes you to the correct route. This is the reason it works with hashes. If you just add a regular URL to the HTML, the browser's native behavior is to actually navigate to this page (hard-link). This leads to your experienced reload effect.
The way to handle this, is, to never use regular links to route within a Vue Single-Page-Application. Use the tag <router-link> for routing between one page and another (but only within the SPA). This is the way to go, no matter if the browser allows the navigation with # without reloading or not. Here is the documentation for the recommended routing tag: link
You can also route from one route to another programmatically. Use $router.push() for that. Here is the documentation for that: link

Change link behavior for non-existent files / broken links

When users click on a link to a file (eg: csv, zip), there are two things that could happen:
If the file exists: it starts downloading (the web page does not change).
If the file does not exist: the user will be redirected to a 404 page (default or custom).
If when the file exists there's no redirection (or to be proper, the user doesn't get the idea of), why is there a redirection when the file doesn't exist?
I understand that when the browser gets a 404 response code, it needs to somehow display it to the user, but shouldn't it take into consideration the event that triggered the request? It is not the same to type an incorrect URL in the address bar than to click on a link. Wouldn't the browser showing an alert and remaining on the same page be a more "appropriate behavior"?
It would be relatively easy to create some back-end (or front-end) script that checks all the links, verifies if the files exists (or not), and then replaces the behavior accordingly. But is there something different that can be done? is it possible to (programatically) change the browser's settings so it doesn't redirect if the file doesn't exist? Or have the server return an HTTP code different than 404 (maybe in the 400s family) to cause such behavior?

How to set jsp pages unaccessible from addressing via browsers in Apache Sling?

I am developing a sling WCMS.
When I call address [e.g. 'http://localhost:8080/apps/bcms/pages/test.jsp'] of a page in the browser, a save dialog box will appear and ask to save jsp file.
How to prevent jsp pages accessible via direct addressing?
Just remove the permissions for anonymous. The script resolution and execution runs with the script user.

default Twitter button doesn't load image

I went to Twitter's resource page here (https://twitter.com/about/resources/tweetbutton) and got the following code:
Tweet<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
When I put this in my Wordpress template, I don't get the Twitter button -- I just get the text "Tweet". However, when I change the src for widgets.js to include https:// or http:// at the beginning it works.
Could it be that it's just an error that they forgot the protocol? Also, do you think it is better to use https (for consistency with the share link) versus http, or does it not matter?
Thanks for your suggestions.
The URL "//example.com/script.js" tells the browser to open the URL using the protocol of the current page, which is likely to be "file://" if your browser opened an html file on your own machine. Of course, you don't have a file called "file://example.com/script.js" on your computer.
In the past, urls for embedded widgets used to include the protocol (http or https), but a site visitor would receive warnings whenever a secure page loaded a script from an insecure page, and sometimes even vice versa. Now, widgets from Twitter, Google Analytics, and other sites no longer specify the protocol so that the same embed code can work on any page on the internet. The downside is that this does not work when you embed such a widget into a file and view it on your own browser by double-clicking it!

customizing apache tomcat authentication Required popup

i want to add a "register" link into the apache authentication popup.
i would also like to change the error message page that is called when you press cancel.
i looked into directory www/error where i found some files but it seem none of those files is the error page that is called.
how can i find the Authorization Required page that is called ?
so i can change it.
You can't - that's native browser behavior, not an Apache popup. Try different browsers and see how they do the popup differently.