How to hide or disable the address bar on Edge? - javascript

My team and I are trying to enable an old application that runs on IE to be compatible with Edge.
The main issue we have is we are required to either: 1- Disable the address bar so the user is unable to copy or modify its parameters or 2- hide it completely so users are not able to access it.
The application was built on Struts 2, Java 1.7 for the backend, and it uses JSP and JavaScript for the front end. We have searched everywhere and we have been unable to find a solution to this issue.

You said,"The main issue we have is we are required to either: 1- Disable the address bar so the user is unable to copy or modify its parameters or 2- hide it completely so users are not able to access it."
The Edge browser does not support hiding the address bar.
As a workaround, you can try to install that site as an app.
To add the site as an App, go to Settings and more(ALT + F)-> Apps-> Install this site as an app.
Now if you launch the app, it will not display the address bar.
But users can open the site in the Edge browser from the app, so not sure whether this is suitable for you.
If your requirement is that users should not able to modify/ copy the parameters then I suggest you make the post requests instead of Get requests. It may help you to avoid this issue.

When opening edge use `prefix --app="www.google.com"
or
%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe --app="www.google.com"
this will hide the address bar

Related

Automatic back button functionality in UWP (JS) App

I have a UWP (JavaScript PWA template / VS 2017) that is meant for testing and development of a hosted application. There is not much fancy about it besides letting a developer or tester choose which application build it should navigate to. However, one thing annoys me and I cannot seem to fix it. In a previous incarnation of this UWP, anytime I opened it on Windows 10 and navigated to an app build, it would show a back button at the top that I could use to go back to the index.html for the UWP.
I have scoured the old code to see if I was missing something. I was thinking perhaps I had left out some code to enable the back button and handle when it is clicked. Something that might have looked like this:
// This is javaScript
const navigationManager = window.Windows.UI.Core.SystemNavigationManager.getForCurrentView();
navigationManager.appViewBackButtonVisibility = window.Windows.UI.Core.AppViewBackButtonVisibility.visible;
navigationManager.addEventListener("backrequested", window.history.back, false);
However, there was no such code in the old version. I also checked the code for the hosted app and I didn't find anything like it either. Regardless, whenever I open the old solution for this UWP, I get a back button with all the expected functionality but without any code to handle it.
Is there some kind of declaration in the app manifest or .jsproj maybe? Something that tells the application at build time that we want a back button that works "out of the box"?
UPDATE
I recreated the UWP with a fresh template and did some tests on it. The template automatically sets the start page to https://example.com and on this site there is a link for https://www.iana.org, so I whitelisted that domain in the content URIs. Navigating to the link there works. I get a back button.
Next, I replaced the template code with my own code, pointed it to index.html as the start page, and set up the content URIs. When I try to navigate to anything, I do not get a back button. Even if I go to https://www.iana.org, I do not see a back button.
Last, I replaced the start page with https://example.com. When I click the link on that page for https://www.iana.org, I get a back button.
I also removed all JavaScript utilizing WinRT in order to check if something there might be messing with it, but it had no effect.
Additional Info
After having a look at the old version, a major difference I see is that the index.html for the app was actually hosted and in my version it is part of the app. Per recent comments on this question, it seems that the back button functionality only works for hosted content?
For security reasons, the PWA project requires the project to run in the https environment, or it can be run in localhost when debugging locally.
The PWA project in UWP is to package the existing PWA program. This requires that the PWA project is already in the https or localhost environment. You can view some requirements of the PWA project here
Thanks.

Detect supported protocols in browser

I have a web page, where i would like to add links using a custom protocol, to open in my desktop application. For example "myprotocol:www.mytestpage.com".
My issue is, how do I detect, using javascript, if the user has registered my protocol?
If for example I use the link above in firefox, withouth having the protocol registered, I am just taken to an error page. Instead I want to show a dialog telling the user to download my application.
As far as I know you cannot tell whether the protocol has been registered or not.
This answer should give you a step in the right direction. https://stackoverflow.com/a/24129863/7326037

how to code for users with disabled cookies and popups

Here's the situation: I'm redesigning our company's public facing website using ASP.NET, VB.NET and some javascript/jquery. Some of the features I'm adding require page reloads (which register as popups) and cookies. Works great if everything is enabled. But I've noticed on some browsers (such as Firefox) I still get prompted to ok these actions, retain these cookies, etc. Now I can code some contingencies for simpler pages for users who will not or can not enable these features, but I'd like to find a way to make it as simple as possible to enable the full features. From what I've read, there's no way I can actually force it to happen the way you can force a browsers document mode by settings in the web.config file, but I am hoping there is some way to give them a button to click (or something similar) where it will enable what I need. Is there a way to do this programmatically? what I'm looking for is some code that will make the changes, instead of directing them to go into e.g. Internet Explorer security settings, which most end users find tedious if not incomprehensible.
Advice?
You can avoid using cookies. Use Session or a database backend for things you would normally use cookies for. For popups, use overlaid divs such as Ajax Control Toolkit Modal Popup Extender or jQuery UI Dialog instead of starting a new browser window.
But really, ASP.NET is designed to function with cookies. If you're users aren't using them, tell them they're penalizing themselves.
Certain browser features are ONLY user-configurable for security reasons. You cannot provide a button to change these settings because they would then not user-configurable.
All you can do is warn the user.
JavaScript cannot change a client browser's setting due to security reason. Otherwise, all hell will break loose.
Note: you can if you create an executable program, and a user runs on his/her computer.
However, you should never change a user's browser setting.
Instead you should give the warning and instruction to a user which is a proper way of doing it.
Disable Javascript
Disable Cookie

Prevent tweet URLs from being opened by native Twitter app on Android

I'm working on an app built in Titanium that has a few "Tweet about this" buttons. Since I can't use the Javascript part of a Tweet button as described in Twitter API, I just use a plain URL with parameters.
On Android, this causes problems. When users click this link, they get a choice how to open it: always the native browser, and additionally any app that has registered for this kind of link. So if the user has the Twitter app installed, Twitter will be shown as one of the options.
That would be great, except the Twitter app is awful. Most types of suggest-a-tweet URL cause the app to crash, and the few that do work don't pass the status text.
I'm looking for a way to force the URL to be opened by the native browser. (Or way to prevent the Twitter app from being among the options presented to the user, but that seems harder to do)
Is this possible using only the URL itself, or maybe a little Javascript? Since I'm using Titanium, Java won't help me.
I can't give you what you want but give you an alternative suggestion.
What you are trying is hard (often impossible to do without errors) even with native code as your trying to work against the OS. Intents are used in android as a way to let the user decide which program should handle a certain request. If you don't want the user to take this decision I'd suggest opening the url in a embedded browser.

Can I use javascript to add a bookmark that is not a http url?

I have this bookmarklet, i.e. it does not start with 'http:' but with 'javascript:'. No issue with that, it works correctly.
The problem occurs when I want to deploy this to users. I'd like to present them a link they'll just click to add to their favorites. Whatever methods I use (examples found on the web, or JQuery with jFav), I end up with a javascript error 'permission denied' when clicking the link, though it works perfectly when the link to bookmark is a classic 'http' one.
I believe that's some security in browsers, but is there a way to avoid this?
It is indeed a security measure. If a user could be tricked into bookmarking and running a javascript: URL, that's pretty much global cross-site-scripting.
About all you can do is present the user with a javascript: link, and ask them to bookmark it via right-click-bookmark or drag-to-bookmarks. You should also write the link out so it can be copy-and-pasted and manually bookmarked, because some browsers won't present right-click-bookmark for a JavaScript link, and others may not have a bookmarks bar visible.
You can ask your users to drag and drop the bookmarklet to the their bookmarks or toolbar.

Categories