How to disable this annoying contextmenu in chrome while on a touch screen. This pops up on selection/on long tap of any input while i have some text copied.
Am developing an app using CEFSharp (Chromium Embedded Framework) and its going to be deployed on touch screen on windows 8 machine. am using a on screen keyboard(http://mottie.github.io/Keyboard/) for entering text in input fields.
I have tried
$('input').bind('copy paste contextmenu', function (e) {
e.preventDefault();
e.stopPropagation();
});
this disables the pasting but the menu still shows up. how do i get rid of this menu? how best to approch this: CSS , Javascript or through chrome command line arguments (http://peter.sh/experiments/chromium-command-line-switches/) ?
i know you said JS / CSS, but this worked for me
var browser = new ChromiumWebBrowser("http://www.afrobotics.co.za")
{
Dock = DockStyle.Fill,
DragHandler = new DragHandler(),
MenuHandler = new ContextHandler()
};
//
public class ContextHandler : IMenuHandler
{
public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
{
return false;
}
}
public class DragHandler : IDragHandler
{
public bool OnDragEnter(IWebBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return true;
}
}
Related
I have a web browser control in my application which contains the following link:
<html>
<body>
test
</body>
</html>
Each time I click on this link, it gets opened in a new window of IE instead of a new Tab. I tried loading this html directly in IE - then it correctly gets opened in new tabs.
I have also configured the IE setting to open links in new tabs instead of new windows.
Can anyone help me out to load the links from the web browser control in a new tab?
Thank you!
It would have been helpful if you had specified whether you were using Winforms or WPF for your web browser control or even what language you were using (C#, VB,F#, etc) but assuming you are using winforms and C# this solution would work.
You simply cancel the new window event and handle the navigation and tab stuff yourself.
Here is a fully working example.
using System.ComponentModel;
using System.Windows.Forms;
namespace stackoverflow2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webBrowser1.NewWindow += WebBrowser1_NewWindow;
this.webBrowser1.Navigated += Wb_Navigated;
this.webBrowser1.DocumentText=
"<html>"+
"<head><title>Title</title></head>"+
"<body>"+
"<a href = 'http://www.google.com' target = 'abc' > test </a>"+
"</body>"+
"</html>";
}
private void WebBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true; //stop normal new window activity
//get the url you were trying to navigate to
var url= webBrowser1.Document.ActiveElement.GetAttribute("href");
//set up the tabs
TabPage tp = new TabPage();
var wb = new WebBrowser();
wb.Navigated += Wb_Navigated;
wb.Size = this.webBrowser1.Size;
tp.Controls.Add(wb);
wb.Navigate(url);
this.tabControl1.Controls.Add(tp);
tabControl1.SelectedTab = tp;
}
private void Wb_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
tabControl1.SelectedTab.Text = (sender as WebBrowser).DocumentTitle;
}
}
}
I have a strange behaviour in my Xamarin.Forms app on the WinPhone client.
My MainPage is a NavigationPage. And when I navigate to the second page and turn the phone to landscape (also happens on the other way), the page shows a black area on the right side. It seems that the height and width properties don't get re-calculated on the device orientation change.
To reproduce this, just create a new Xamarin.Forms Blank App (Visual Studio 2013 template), Update the Xamarin.Forms nuget to the newest verson (in my case: 2.0.0.6490), and add the following to the App-Constructor:
var second = new ContentPage
{
BackgroundColor = Color.Green,
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Second Page"
}
}
}
};
var button = new Button {Text = "Show Second"};
button.Clicked += async (sender, args) => { await ((NavigationPage) MainPage).PushAsync(second); };
var firstpage = new ContentPage
{
BackgroundColor = Color.Blue,
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "First Page"
},
button
}
}
};
// The root page of your application
MainPage = new NavigationPage(firstpage);
Is this a bug in Xamarin.Forms? Or miss I just something? Thanks in advance
I cant see any existing filed bugs on this. If it is easily reproducible as described, then create a small repro project and submit to bugzilla.xamarin.com. It will be a xf regression bug.
Thanks #Joehl - I obviously am not too great at searching bugzilla on my mobile. As mentioned this is the bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=36477
My Chrome extension has a page that is seen in a popup or as a separate tab. When it seen as a separate tab, I need to show a small button at the corner of the page. But I couldn't find a way to detect when a page is loaded in its own tab.
Use chrome.extension.getViews, which returns an array of window objects.
var tabs = chrome.extension.getViews({ type: "tab"})
if(tabs[0]) {
console.log("inside tab")
}
var popups = chrome.extension.getViews({ type: "popup"})
if(popups[0]) {
console.log("inside popup")
}
Or chrome.tabs.getCurrent, which returns a tab object in the callback.
chrome.tabs.getCurrent(function(tab) {
if(tab) {
console.log("inside tab")
} else {
console.log("inside popup")
}
})
I created an HTML page that has some external links, when the user taps the external link how can I prompt the user that there is no internet connection available? Thanks.
You will probably need some JavaScript and Adobe's store api (for banners or store) or reading api (for html articles or web view in folios). The api provides the singleton object adobeDPS.deviceService which can tell you if the device is online or not. Additionally it provides a signal to indicate a change.
For each link element you register an onclick event handler that checks online state and either passes the click through or catches it and gives a message to the user.
The following code could work:
<script src="js/AdobeLibraryAPI.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", myLinkChecker.register, false);
var myLinkChecker = {
register: function(){
if (typeof(adobeDPS) !== 'object') {
console.log("Adobe Library not loaded :-(");
this.check = function() { return true } // Fallback
}
var linkList = document.querySelectorAll("a, map > area");
for (var i=0; i < linkList.length; i++){
var e = linkList[i];
if (e.hasAttribute('href'))
e.addEventListener('click', myLinkChecker.check, false);
}
},
check: function(ev){
if (adobeDPS.deviceService.isOnline) { // let <a> process the click
console.log("online");
return true
} else { // cancel click event and show message
event.stopPropagation();
event.preventDefault();
alert("Sorry, your device is not online")
return false;
}
}
}
</script>
Remote debugging html in DPS apps can be done using iOS developer apps and desktop Safari, or Android apps with Google Chrome.
I am creating an application using HTML5 where I would like to be able to drag a local text file into a textarea. This works fine in Firefox 20.0.1, Chrome 26.0.1410.64 m and Internet Explorer 10 but not in Opera 12.15 or Safari 5.1.7. Instead of the text of the file appearing within the text area a new page opens containing the text. I understand from this answer that I should expect problems from Safari however the implication is that it should work with Opera 12.
Any help explaining or overcoming the problem would be appreciated.
The application, which is nowhere near finished, is at grideasy.github.io with the source files at https://github.com/grideasy/grideasy.github.io
To see the effect click on the 'Content' button and drag a text file into the text area.
Both Safari and Opera pass the detect feature code below
if(window.File && window.FileReader && window.FileList && window.Blob) {
dropZone = $('drop_zone');
dropZone.value="";
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
dropZone.addEventListener('click', storeCursorPosition, false);
dropZone.addEventListener('keyup', storeCursorPosition, false);
}
else {
}
this is found in lines 30 to 41 of the event.js file
The following code from dropcontent.js reads the file and displays the text from the file.
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
}
function handleBodyDrop(evt) {
evt.stopPropagation();
evt.preventDefault();
}
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
var f = files[0];
if (f)
{
var r = new FileReader();
r.onloadend = function(e) {extract(e.target.result) }
r.readAsText(f);
}
else
{
alert("Failed to load file");
}
}
function extract(a) {
$('drop_zone').value=a;
}
Thank you for any suggestions
It appears that Opera will not accept a textarea as an object that can be used as a dropzone. Changing the textarea to a paragraph, span or div will allow that area to accept a draged and dropped file.