Safari in fullscreen mode ahref target "_blank" does not open in new window - browser

We have an app that opens in a new window (popup) with defined window size. There are links in the app that open another external links.
We have a code to handle ahref links to open in a new window using target as "_blank".
It works fine with all the browsers except in Safari when the popup window is changed to fullscreen mode. Once in fullscreen mode the external links (even with _blank) open in the same window and replace the content of the main window.
I want to open the external links in a new tab/window always.
Please help.
handleLinks: function (link) {
var url = link.href;
if (url && !url.indexOf('http')) {
link.target = '_blank'
link.rel = 'external';
} else if (url && !url.indexOf('mailto')) {
// FIX FOR CHROME BROWSER NOT TO OPEN IN A BROWSER TAB FOR MAIL CLIENT
link.target = '_top';
}
}

Related

Disallow page closing in Xamarin.iOS during background actions

In my IoT mobile app, I created a page showed on iOS device as UIModalPresentationStyle.PageSheet.
During the page load I don't want the page will react to user interaction, in particular I don't want the page will be closed, because the app interacts with a physical device.
The page will be enabled to be closed once all the background tasks will be completed.
I tried to set the page property IsEnabled to false, but again I'm able to close the page.
That's a code snippet from the page constructor
public ParametersListPage(ControlUnitParametersCategory parametersCategory, bool isParametersListReadOnly = false)
{
InitializeComponent();
IsEnabled = false;
On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.PageSheet);
MessagingCenter.Subscribe<ListParamsViewModel>(this, Constants.ACTION, async (sender) =>
{
IsEnabled = true;
await DisplayAlert(Resource.DoAct, Resource.DoActMsg, "OK");
}
);
What Am I missing?
Thank you
Do you want to disable user actions during interaction? If so, you can try setting the UserInteractionEnabled property to false to disable the user's actions so that the user will never be able to trigger any events (including touchscreens).
For Xamarin.Forms you can refer to the following code:
MyPageRenderer:
[assembly:ExproRenderer(typeof(ParametersListPage),typeof(ParametersListPageRenderer))]
namespace FormsDemo.iOS
{
public class ParametersListPageRenderer:PageRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
this.View.UserInteractionEnabled=false;
}
}
}
If you just want the user not to close the page during interaction, it is better to set a popup reminder.

Webview issue, pdf links do not open, please assist

Im trying open pdf`s from a selectable list with a wevbview but when I click in app nothing happens, I have given the app internet permision also read and write(tough not needed) to ext storage. Can anyone give me a hint?
I have tested the google docs version it works with it but there are login and print buttons there where they dont work in webview, and Id like users to save the pdf they pick to view
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.endsWith(".pdf")){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
try{
view.getContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
//user does not have a pdf viewer installed
}
} else {
webview.loadUrl(url);
}
return true;
Ok so I changed the code so instead of viewing in the webview it should just download the file. I still have no idea why the above code was not calling the default pdf viewer on the device.I had installed over 5 pdf viewers on my device and made at least 3 of them default to test - didnt work. So in the end I just changed the shouldOverrideUrlLoading to download the file in the ext storage and from then, the user can open it by any app he wants/has installed. Solution:
public boolean shouldOverrideUrlLoading (WebView view, String url) {
if (url.endsWith(".pdf")) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
return false;
}
also added permissions to manifest to access the default download manager and external storage
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
this fixed it for me.

Android Studio - prompt to open a downloaded file with any application available

I have an application which receives urls from a server, using Firebase. When the url is received, the file at that url is automatically saved on the local storage (they are gpx files).
But after this, I want my application to prompt the user to open the downloaded file with whatever navigation application they have installed on their phone. Something similar to when you go to the file manager yourself, click on a file, and the system shows you all applications which could open that file, and lets you chose (or opens it directly with your default setting, if you have one).
I have not been able to find anything about this, and searches containing "android studio" and "open file" show mostly tutorials about how to manage the source files themselves, so they are not helpful at all.
You could do something like:
String mimeType = myMime.getMimeTypeFromExtension(fileExt(getFile()).substring(1));
newIntent.setDataAndType(Uri.fromFile(getFile()),mimeType);
private String fileExt(String url) {
if (url.indexOf("?") > -1) {
url = url.substring(0, url.indexOf("?"));
}
if (url.lastIndexOf(".") == -1) {
return null;
} else {
String ext = url.substring(url.lastIndexOf(".") + 1);
if (ext.indexOf("%") > -1) {
ext = ext.substring(0, ext.indexOf("%"));
}
if (ext.indexOf("/") > -1) {
ext = ext.substring(0, ext.indexOf("/"));
}
return ext.toLowerCase();
}
}
This allows you to get the type based on file extension. Then just startActivity passing in the newIntent. This should achieve what you are looking for.

page object watir cucumber test for file being downloaded

I'm trying to test that a file downloaded is initialized when i click on an image. So far i've been unable to find anything that seems to work with page object.
More specifically i'm looking for a way to handle the download dialogue pop up and to verify that file.exe has begun downloading.
Thank you
You can activate some option when you launch your browser. Here an example I use :
# create the folder location
download_directory = "#{Dir.pwd}/downloads/"
download_directory.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
# Create the firefox profile
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = download_directory
profile['download.prompt_for_download'] = false
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/octet-stream,text/csv,application/pdf"
profile['network.http.use-cache'] = false
# launch FF
#browser = Watir::Browser.new :firefox, profile: profile
Then you don't need to handle the window, but only to check the downloaded file in the folder you define.
For chrome, you can't use a profile, but should use preferences.
# Create the prefs
prefs = {
download: {
prompt_for_download: false,
default_directory: #download_directory
}
}
# Launch chrome
#browser = Watir::Browser.new :chrome, prefs: prefs
And no, I don't find a solution for internet explorer yet.

content script - window.location.href = url_b; lands on about:blank page

In my content script
var url_b = 'chrome-extension://abcdefghijklmnopqrstuv/page_b.html';
window.location.href = url_b;
takes me to about:blank instead of chrome file
'chrome-extension://abcdefghijklmnopqrstuv/page_b.html' url is valid and works when opened in a new tab
same code if url_b = 'www.gmail.com'
takes me to gmail. works fine.
to reproduce.
1.open gmail.com in a tab
2.open console and command in 'window.location.href = chrome-extension://any sample file'
3.about:blank opens
4.run step 2 again
5.sample page opens

Resources