I am developing an app for Windows 8.1. I tried below code it's not working.
<WebView Source="http://wikipedia.org"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollMode="Disabled"/>
Is there any JavaScript solution to disable touch, mouse & key board scrolling?
I have used below given JS for my requirement. Though I am waiting for a better (XAML) solution.
function RemoveScrolling()
{
var styleElement = document.createElement('style');
var styleText = 'body, html { overflow: hidden; }'
var headElements = document.getElementsByTagName('head');
styleElement.type = 'text/css';
if (headElements.length == 1)
{
headElements[0].appendChild(styleElement);
}
else if (document.head)
{
document.head.appendChild(styleElement);
}
if (styleElement.styleSheet)
{
styleElement.styleSheet.cssText = styleText;
}
}
Related
I have used some code to automatically follow someone on Instagram in Greasemonkey but when I try it in Tampermonkey in Chrome I get a symbol with an exclamation mark saying 'filterArrButtons' is not defined.
Here is the code
window.addEventListener('DOMContentLoaded', function() {
setInterval(function() {
var btns = document.getElementsByClassName("_5f5mN");
for (var i = 0; i < btns.length; i++) {
if (btns[i].innerHTML == "Follow") {
btns[i].click();
}
}
for (var x = 0; x <= filterArrButtons.length - 1; x++) {
var df = filterArrButtons[x].classList;
df = df.value.split(" ");
simulateCliks(filterArrButtons[x], "click");
}
}, 2000);
});
function simulateCliks(el, evntType) {
if (el.fireEvent) {
el.fireEvent('on' + evntType);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(evntType, true, false);
el.dispatchEvent(evObj);
}
}
});
And here is a screenshot of the error I'm getting
enter image description here
I've tried searching for an answer to the problem I'm getting but I can't find anything. It works in Greasemonkey on Firefox but not in Tampermonkey in Chrome.
run-at
GreaseMonkey and ViolentMonkey defaults to 'document-end' while the Firefox content_scripts default run-at is 'document_idle' and so does FireMonkey and TamperMonkey.
GreaseMonkey document-end
ViolentMonkey document-end
FireMonkey document-idle
TamperMonkey document-idle
document-idle in TamperMonkey means that script is injected AFTER 'DOMContentLoaded', therefore 'DOMContentLoaded' will never fire the event.
The complete script is not shown so it is unclear if run-at is set or left as default.
I tried to test blow code on Android device but i couldn't see any data in text fields. This code works well on AIR Desktop but in Android no. Is it difference between AIR FileStream function on Desktop and Android? Whats best cross platform code to save files and read write?
This code works on Adobe Animate CC Android Emulator.
import flash.filesystem.*;
var prefsFile:File;
[Bindable] var prefsXML:XML;
var stream:FileStream;
function appStart():void
{
prefsFile = File.applicationStorageDirectory;
prefsFile = prefsFile.resolvePath("preferences.xml");
readXML();
}
function readXML():void
{
stream = new FileStream();
if (prefsFile.exists) {
stream.open(prefsFile, FileMode.READ);
processXMLData();
}
else
{
saveData();
}
}
function processXMLData():void
{
prefsXML = XML(stream.readUTFBytes(stream.bytesAvailable));
stream.close();
trace(prefsXML.Data1);
trace(prefsXML.Data2);
trace(prefsXML.Data3);
txt_D1.text = prefsXML.Data1;
txt_D2.text = prefsXML.Data2;
txt_D3.text = prefsXML.Data3;
}
function windowClosingHandler(event:Event):void
{
saveData();
}
function saveData():void
{
createXMLData();
writeXMLData();
}
function createXMLData():void
{
prefsXML = <preferences/>;
prefsXML.Data1 = 1;
prefsXML.Data2 = 2;
prefsXML.Data3 = 3;
}
function writeXMLData():void
{
var outputString:String = '<?xml version="1.0" encoding="utf-8"?>\n';
outputString += prefsXML.toXMLString();
outputString = outputString.replace(/\n/g, File.lineEnding);
stream = new FileStream();
stream.open(prefsFile, FileMode.WRITE);
stream.writeUTFBytes(outputString);
stream.close();
}
appStart();
That's the correct way, we use it for AIR app (Desktop, Android, iOS) to store user data on device/PC, File.applicationStorageDirectory as well. So your code is cross-platform, if it does not work on Android, you probably have some other issue, but your code looks fine.
To read/write data to File.applicationStorageDirectory you don't need any explicit permissions in app manifest as well.
If your Android version is 6.0 or more recent, you need to request permissions such as files or camera at runtime.
Ensure you have AIR 24.0 , with compiler option -swf-version=35, and do something like:
var permissionCheck : File = new File( "test") );
permissionCheck.addEventListener(PermissionEvent.PERMISSION_STATUS , function permissionStatusHandler( e : PermissionEvent ) :void
{
permissionCheck.removeEventListener(PermissionEvent.PERMISSION_STATUS , permissionStatusHandler);
if(e.status == PermissionStatus.GRANTED)
{
// save your file
}
else
{
showPermissionError();
}
});
try
{
permissionCheck.requestPermission();
}
catch(error : Error)
{
}
See the AIR release notes for more info such as handling the camera permission.
https://helpx.adobe.com/flash-player/release-note/fp_24_air_24_release_notes.html
Hope this helps.
I have a Google Chrome App with a webview control. Some of the links in the webview are meant to open in a new tab (target="_blank"). However, clicking those links doesn't do anything, and right-clicking on them doesn't open a context menu to open/copy the link. How can I enable such links?
This is the best I've come up with so far:
var webview = null;
function isSafeUrl(url) {
// You may want to perform a more rigorous check.
// There's a technique that creates an <a> to parse the URI, but that seems
// like a security risk.
return !!url.match(/^(?:ftp|https?):\/\//i);
}
function onNewWindow(event) {
if (!isSafeUrl(event.targetUrl)) {
console.warn('Blocking unsafe URL: ' + event.targetUrl);
event.window.discard();
return;
}
var newWindow = null, features = '';
switch (event.windowOpenDisposition) {
case 'ignore':
// Not sure what this is used by. Default enum value, maybe.
console.debug('Ignoring new window request');
return;
case 'save_to_disk':
// Ctrl + S, maybe? Not sure how to reproduce that.
console.log('save_to_disk is not implemented');
return;
case 'current_tab':
webview.src = event.targetUrl;
break;
case 'new_background_tab':
case 'new_foreground_tab':
newWindow = open(event.targetUrl, '_blank');
if (event.windowOpenDisposition != 'new_background_tab') {
newWindow.focus();
}
break;
case 'new_window':
case 'new_popup':
if (event.initialWidth && event.initialHeight) {
features = 'width=' + event.initialWidth + ',height=' + event.initialHeight;
}
newWindow = open(event.targetUrl, '_blank', features);
newWindow.focus();
break;
}
}
function onDomReady() {
webview = document.getElementById('webview');
webview.addEventListener('newwindow', onNewWindow);
}
document.addEventListener('DOMContentLoaded', onDomReady);
I am creating a page to work on low-end devices. Where JS support may not be available or very poor.
So I want to hit an tag on page load for Tracking purpose.
Please help.
please try this one:
window.whenloaded = function(fn) {
if (window.onload) {
var old = window.onload;
window.onload = function() {
old();
fn();
}
} else {
window.onload = fn;
}
}
DEMO
I'm using a hidden iframe in an HTML page for downloading purposes. And I would like to know when it's done. I've searched the Internet a lot and everyone says that I should use iframe's onload event handler but it's not working for me in Chrome!
I'm not sure where but I read somewhere that it's because I'm downloading files with my iframe instead of HTML documents. And I must admit that it's specific to Chrome and it works fine in FireFox.
I've also tested readstate and onreadystatechange without success.
I've created a fiddle to demonstrate the problem:
function download(url)
{
var iframe = document.createElement("iframe");
iframe.src = url;
iframe.onload = function () {
console.log('Download completed.');
};
document.body.appendChild(iframe);
}
<button onclick="download('http://www.colorado.edu/conflict/peace/download/peace.zip');">Download</button>
function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader',
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
iframe.onload = function () {
alert('Download completed.');
};
document.body.appendChild(iframe);
}
iframe.src = url;
}
<button onclick="downloadURL('http://www.colorado.edu/conflict/peace/download/peace.zip');">Download</button>