Is it possible to get Windows username and PCName with Javascript in browsers IE, Chrome, Firefox, Opera?
No. That sort of information is not exposed to the javascript engine in the browser.
i'd really wish this wouldn't be possible, but sadly it is (or was). i don't know for sure if this still works on Win7 and with current browser-versions, but in the past you could do this...
Internet Explorer
function getUsr() {
var wshell = new ActiveXObject("WScript.Shell");
return wshell.ExpandEnvironmentStrings("%USERNAME%");
}
Related
I want to show a message saying We support Chrome, Safari, Firefox and Edge browsers only conditionally when any user comes from other browsers other than these like Opera etc. So how to achieve this using angular 10? Can anybody show me a small code snippet?
I tried with this code but its working for only chrome.
const userAgent = navigator.userAgent;
let browser = "unkown";
this.browserDetection = (/chrome|crios/i).test(userAgent) && !(/opr|opera|chromium|edg|ucbrowser|googlebot/i).test(userAgent) ? 'Chrome' : browser;
if(this.browserDetection === browser){
this.displayMsg = "*Supported browser is Google Chrome"
}
Thanks.
Generally this type of approach isn't ideal. It's better to solve the issue as to why you need to detect the browser type.
A good article to read is this: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
It gives some great advice and some strings to look for in the user-agent when detecting different browsers.
I am trying to find a way to identify the browser through JavaScript to disable a component based on the browser for a feature requirement in Volvo US project that involves AR (Augmented Reality).
Platform: Web Application
Approach Attempted:
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
var isChromeBrowser = navigator.userAgent.includes("Chrome");
var isFirefox = navigator.userAgent.includes('Firefox');
Problem Statement:
In the above approach, Safari is detecting Firefox browser as Safari browser & Safari browser as Safari.
Expected Output:
Need a solution where the method clearly returns Safari* browser alone as safari. (not for the Firefox browser or any other browsers)
Looking forward to any inputs towards a solution.
Many thanks in advance.
I am listening to a server event via a javascript function on my HTML file, which outputs the server answer in the console tab. Since I need to pass this answer to a delphi application, I made the server answer "visible" via a div container. This works fine on Firefox, but on IE the output is not shown. I have then tried to utilize the value of a textarea, which also works on Firefox but not on IE.
I really wonder why it is so hard to get a console output visible on IE?
document.getElementById('my_div_container').innerHTML = JSON.stringify(my_data_I_want_to_see, null, 4);
document.getElementById('my_textarea').value = JSON.stringify(my_data_I_want_to_see, null, 4);
The above lines show a result on Firefox, but on IE there is no output at all. How can I get my data visible on IE?
I found the root cause why IE did not show any console output. I just found out, that the addEventListener() method I was using is not supported in Internet Explorer 8 and earlier versions.
I am very sorry for any confusion.
If you are using TWebBrowser component in Delphi for displaying the webpage do note that by default it running in Internet Explorer 7 compatibility mode.
In order to avoid this you need to opt your program into browser emulation feature
How to have Delphi TWebbrowser component running in IE9 mode?
Don't forget to check MSDN documentation for proper registry value to enable emulation of most modern IE versions.
I'm using Firefox Quantum (64.0) and the JS command new WebSocket() returns a different object from the specification:
MDN Websocket
HTML Standard
The missing property that is affecting my appllication is the .close() function, but there is another differences.
You can see in the image bellow that the returned object has a .websocket porperty that contains all the missing ones.
websocket object
Am I doing something wrong? With older versions of Firefox (before Quantum, like 43) or with chrome it works fine.
If it is a problem with firefox, how can I report it?
EDIT:
Adding some code example:
var exampleSocket = new WebSocket("wss://echo.websocket.org");
exampleSocket.close() // Throw "exampleSocket.close is not a function" in Firefox Quantum, works on chrome
exampleSocket.websocket.close() // Works on Firefox, Throw on chrome.
This exampleSocket.websocket is not in the documentation.
Edit2:
I tested in other machines that have the firefox versions 60, 61, 63 and 64 and the problem only happened in my machine.
When I removed all plugins from firefox it started to work again.
The problem was the websocketsniff plugin that I had installed.
It even state that the WebSocket object will change:
Inspect websocket frames in Firefox. How to use: 1) Open Developer
Tools 2) Open "Websocket Sniffer" tab
This extension replace native websocket object for custom object. It
is dirty hack, but it is single decision
Does anyone know if IE has an equivalent to Chrome's window.peformance.memory property?
I am trying to find a way to analyse IE's memory performance in my application.
Running my js script using a Chrome browser is no problem, because Chrome has added a proprietary memory property to window.performance (see window.performance.memory for more info).
The way I do it in Chrome is like this:
browser.driver.executeScript(function () {
return window.performance.memory; // this is the problem, IE has no memory property
}).then(function (result) {
logResults(result.jsHeapSizeLimit);
logResults(result.usedJSHeapSize);
logResults(result.totalJSHeapSize);
}
});
Internet explorer, use navigation.performance to make other types of measurements. More reference to speed.
https://developer.mozilla.org/en-US/docs/Web/API/Performance
For example: window.performance.now()
On this page you can see all the data that can be obtained with internet explorer or other browsers. You must enter with the internet explorer in the url, to see the data with the browser
https://browserleaks.com/javascript
Other option is using: CTRL+Shift+U keys