Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: Detect
- Original author: Capitán
- Original date: May 8, 2016
- Source thread: https://forums.rpgmakerweb.com/threads/detect.61574/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > JS Plugin Releases (RMMV)
Summary
Synopsis I made this because I needed this. This snippet gives functions to detect the user's browser or operating system. Detectable Browsers are: Google Chrome, Mozilla Firefox, Internet Explorer, Microsoft Edge, and Safari. Detectable Operating systems are Linux, Unix, Windows and Mac
Archived First Post
Synopsis
I made this because I needed this. This snippet gives functions to detect the user's browser or operating system.
Detectable Browsers are: Google Chrome, Mozilla Firefox, Internet Explorer, Microsoft Edge, and Safari. Detectable Operating systems are Linux, Unix, Windows and Mac
How does it work?
Detect the browser by calling the function
This function will return one the following as a string:
If you have a browser that you would like added please tell me and a I will add it if deemed necessary.
Detect the operating system or mobile device by calling the function
This function will return one of the following as a string:
"Windows", "Mac OS", "Unix", "Linux", "iOS", "Android", "Windows Phone"
Updates:
5/8/2016 - Can detect mobile devices
Code:
Download detect.js
var Detect = {
browser: function() {
var n = navigator.userAgent.indexOf(" Edge/") >= 0,
e = !!window.opera || navigator.userAgent.indexOf(" OPR/") >= 0,
o = "undefined" != typeof InstallTrigger,
i = (Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") > 0, !!window.chrome && !e && !n),
r = !!document.documentMode;
return 1 == e ? "Opera" : 1 == o ? "Mozilla Firefox" : 1 == i ? "Google Chrome" : 1 == r ? "Internet Explorer" : 1 == n ? "Microsoft Edge" : void 0
},
OS: function() {
var n = "Unknown OS";
return -1 != navigator.appVersion.indexOf("Win") && (n = "Windows"), -1 != navigator.appVersion.indexOf("Mac") && (n = "MacOS"), -1 != navigator.appVersion.indexOf("X11") && (n = "UNIX"), -1 != navigator.appVersion.indexOf("Linux") && (n = "Linux"), navigator.userAgent.indexOf("iPhone") >= 0 && (n = "iOS"), navigator.userAgent.indexOf("Android") >= 0 && (n = "Android"), navigator.userAgent.indexOf("Windows Phone") >= 0 && (n = "Windows Phone"), n
}
};
I recommend that you place this in the libs/ folder instead of the plugins folder to make the Detect function universal for all plugins.
Usage
Feel free to use in commercial or non-commercial credit is appreciated but not necessary.
I made this because I needed this. This snippet gives functions to detect the user's browser or operating system.
Detectable Browsers are: Google Chrome, Mozilla Firefox, Internet Explorer, Microsoft Edge, and Safari. Detectable Operating systems are Linux, Unix, Windows and Mac
How does it work?
Detect the browser by calling the function
Code:
Detect.browser()
This function will return one the following as a string:
Code:
"Google Chrome", "Mozilla Firefox", "Internet Explorer", "Microsoft Edge", "Safari"
If you have a browser that you would like added please tell me and a I will add it if deemed necessary.
Detect the operating system or mobile device by calling the function
Code:
Detect.OS()
This function will return one of the following as a string:
"Windows", "Mac OS", "Unix", "Linux", "iOS", "Android", "Windows Phone"
Updates:
5/8/2016 - Can detect mobile devices
Code:
Download detect.js
var Detect = {
browser: function() {
var n = navigator.userAgent.indexOf(" Edge/") >= 0,
e = !!window.opera || navigator.userAgent.indexOf(" OPR/") >= 0,
o = "undefined" != typeof InstallTrigger,
i = (Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") > 0, !!window.chrome && !e && !n),
r = !!document.documentMode;
return 1 == e ? "Opera" : 1 == o ? "Mozilla Firefox" : 1 == i ? "Google Chrome" : 1 == r ? "Internet Explorer" : 1 == n ? "Microsoft Edge" : void 0
},
OS: function() {
var n = "Unknown OS";
return -1 != navigator.appVersion.indexOf("Win") && (n = "Windows"), -1 != navigator.appVersion.indexOf("Mac") && (n = "MacOS"), -1 != navigator.appVersion.indexOf("X11") && (n = "UNIX"), -1 != navigator.appVersion.indexOf("Linux") && (n = "Linux"), navigator.userAgent.indexOf("iPhone") >= 0 && (n = "iOS"), navigator.userAgent.indexOf("Android") >= 0 && (n = "Android"), navigator.userAgent.indexOf("Windows Phone") >= 0 && (n = "Windows Phone"), n
}
};
I recommend that you place this in the libs/ folder instead of the plugins folder to make the Detect function universal for all plugins.
Usage
Feel free to use in commercial or non-commercial credit is appreciated but not necessary.
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
Feel free to use in commercial or non-commercial credit is appreciated but not necessary.
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...