Does Javascript features change by browser? [duplicate] - javascript

This question already has an answer here:
Why Javascript upload chunk sizes change by browser?
(1 answer)
Closed 8 years ago.
I wonder something about Javascript. Does Javascript features or behaviors change by browsers?
While I was working Javascript XMLHttpRequest upload method, I noticed that Internet Explorer sending small bytes but Firefox and Google chrome sending big bytes. So while I was sending big data with Firefox or Chrome, server is giving OutOfMemory exception.
I am editing post with image details.

No Javascript features doesn't change from browser to browser, it depends upon their Javascript rendering machine (interpreter is the difference).
For example:
Google - v8 engine
Safari - JavaScriptCore

yes there is some differences (a hanful actually)
here are some examples
1- accessing the float proparity
because float is a reserved keyword you can access it in ie with:
document.getElementById("id").style.styleFloat = "left";
while in fire fox it will be :
document.getElementById("id").style.cssFloat = "left";
2-to access a class attribute you can do the following in ie :
document.getElementById("id").getAttribute("className");
while in fire fox :
document.getElementById("id").getAttribute("class");
these are the things that i had an experience with . but mostly every one is using jquery now so no need to worry about those . but here are some articles about them
http://www.impressivewebs.com/7-javascript-differences-between-firefox-ie/
http://www.willowdesign.info/blog/tag/javascript-browser-differences/
JS cross browser inconsistencies/differences
http://technologypost.blogspot.com/2008/07/ie-vs-firefox-javascript-differences_05.html

Related

Capture Image from Webcam through js/JavaScript [duplicate]

This question already has answers here:
How can I capture an image via the user's webcam using getUserMedia?
(3 answers)
Closed 2 years ago.
I am looking to capture the image from the webcam.
I have tested quite a few libraries including
https://github.com/jhuckaby/webcamjs
https://github.com/amw/jpeg_camera
But all existing libraries are very old and no longer maintained by authors.
I have also tried "navigator.mediaDevices.getUserMedia" to capture the image but it does not work with safari.
I am wondering if you can suggest something that works cross-browsers and can manage a responsive view as well.
Thanks.
The navigator.mediaDevices.getUserMedia method should work with the latest version of safari 11. You'll want to use the MediaDevices.getUserMedia() method which has full support by almost every latest browser (except IE).
Note that if your writing an HTML file and opening it in the browser, it may not work because your browser may require a secure context (HTTPS instead of HTTP) to use that method.
See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Also, Sam Dutton created a great example, and you can find the github code for it as well.

Make that the website becomes chrome's default start up page when a particular button is clicked [duplicate]

This question already has answers here:
How can I set default homepage in FF and Chrome via javascript?
(7 answers)
Closed 4 years ago.
I made a page redirection website for school and I was wondering if there is a way to avoid going in chrome settings and manualy setting up default browser start up page for each computer in the class.
Is there a way to access these chrome settings with JS or any other language?
Because of security restrictions, this can't be done. If such JavaScript existed, a malicious website could easily change your homepage without even asking or requiring you to click a button to do so.
Since you're in a classroom environment, I assume all the computers are managed on a network using some sort of Group Policy. You can use a Group Policy to set settings on computers on a managed network.
Here is how you could do it specifically for Chrome.
https://support.google.com/chrome/a/answer/187202?hl=en
Note In the olden days of Internet Explorer, circa version 5, you could do this with JavaScript, but IE has never been known to be the best when it comes to adhering to good security protocols.

how can a website detect smartphone model? [duplicate]

This question already has answers here:
Simple Smart Phone detection
(2 answers)
Closed 9 years ago.
How can a website detect the smartphone model of a device that requests a webpage?
Google Analytics can get that information as you can see in the image below:
I found this: http://blog.mobileesp.com/?p=177 but only a few phones are recognized by this script. I am looking for an PHP or Javascript solution
From Javascript you can read this property navigator.userAgent and PHP $_SERVER['HTTP_USER_AGENT'] both return you the browser version .
In my experience, the best method for detecting mobile/tablet is to use the PHP mobile_detect class which is updated regularly as new devices are released. Unfortunately, I don't know if it provides a way to get the different device types.
User agent parsing is the method you'll have to use, and if mobile_detect doesn't have it, it ought to at least give you a good starting point on how it's done.

Where can I find javascript native functions source code? [duplicate]

This question already has an answer here:
How can I see the source of built-in JavaScript functions? [closed]
(1 answer)
Closed 6 years ago.
where can I find the source code of native js functions, for example I want to look at eval() function
Both Chrome and Firefox are open source and you can look at the implementation of any part of the javascript engine in the source code for those products. Other browsers have their own implementation (like IE) that is not available to the public to look at.
The Chrome v8 javascript engine code is here: https://github.com/v8/v8
The Firefox SpiderMonkey engine code is here:
https://searchfox.org/mozilla-central/source/js/src
Warning, if you aren't already familiar with those products and their tools, it may take while to get familiar enough to find what you're looking for.
These links may change over time, but can easily be found with Google searches if they move.
Javascript is a script language that is implemented within a Browser's code-base. This means that there may be different implementations of the script language, with different levels of quality, and possibly different intepretations of what is required. Hence the head-against-wall frustrations of many a web-developer when dealing with different web-browsers.
It is possible for you to examine a browser's implementation of Javascript if the browser is an Open Source version, eg: Chrome, Firefox, as given in other answers listed.
In the JavaScript engine's source code.

How to get a name of browser by using JavaScript? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Reliable browser detection with javascript?
How to get a name of browser by using JavaScript?
I expected to see only the name like this Firefox, Chrome, Safari etc.
If you're sure you need it: jQuery.browser. Promise you'll only use it as a last resort.
Take a look at jQuery.browser, but read the warning, it's better to detect features. What are you trying to achieve?
There is no way to confidently "get" only the name in a cross browser manner.
The best you can do is hack around with regular expressions on window.navigator.userAgent and hope future browsers don't break it.
But the userAgent is a mess. Don't touch it.
The W3C claims that
window . navigator . appName
Returns the name of the browser.
This is false as window.navigator.appName in chrome returns "NetScape"
The `Navigator object is very poorly implemented in browsers
Do not browser detect

Categories