javascript Browser detection
Udaje o prohlížeči
alert(navigator.appName); // Netscape
alert(navigator.appVersion); // 5.0(Windows; en-US)
alert(navigator.appCodeName); // Mozilla
alert(navigator.appMinorVersion); // subverze prohlížeče
alert(navigator.browserLanguage);
alert(navigator.cookieEnabled); // true - false
alert(navigator.cpuClass);
alert(navigator.onLine); // true když je připojen k síti
alert(navigator.platform);
alert(navigator.systemLanguage);
alert(navigator.userAgent);
alert(navigator.userLanguage);
// zjisteni detekce prohlizece Google Chrome
var bool_is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
77LW NO topic_id
AD
Další témata ....(Topics)
Odkazy na online regex editory:
https://regex101.com/
https://www.debuggex.com/r/LyIpMYTAhJ9Gja4x
https://regex101.com/
https://www.debuggex.com/r/LyIpMYTAhJ9Gja4x
Jak vytvořit slovník podstatných jmen.
Velmi snadno. Stačí si stáhnout slovník pro kontrolu pravopisudo Open Office org a tam již druhy slov májí za lomítkem určující znaky.
//wiki.services.openoffice.org/wiki/Dictionaries#Czech_.28Czech_Republic.29
Ukázka obsahu slovníku:
alokuce/Zalokující/YN
alokátor/H
alolex/H
alomorf/H
aloový/YKRN
aloparentální/YKR
alopatický/YCRN
alopatie/Z
Dodržujte licence slovníků
Tthis code works in all previous versions of browsers
Pause code by alert
Set timeout
Pause code by alert
var n = 1;
alert(n);
n = 5;
alert(n);
Set timeout
var n = 5;
// wait 5 second / do next code
// next code put into function and call this function by setTimeout
setTimeout("nextCodeFc (n)",5000); // wait for 5000 millisecond == 5 second and execute
// how put string as parameter into setTimeout
var str = "Hello string parameter!";
setTimeout('nextCodeFc("str")',3000); // produce "str"
setTimeout('nextCodeFc("'+str+'")',3000); // produce "Hello string parameter!"
setTimeout("nextCodeFc(str)",3000); // produce Hello string parameter!
function nextCodeFc (n){
// do work .........
alert(n);
}
Textarea selection - získání pozice karety kurzoru.
// FOR Gecko Browser selectionStart / selectionEnd selection length
function getPos(){
if (typeof document.getElementById('idTextarea').selectionStart != 'undefined') {
var nPosCursor = document.getElementById('idTextarea').selectionStart;
var nEndPos = document.getElementById('idTextarea').selectionEnd;
return nPosCursor;
}
return 0; // or -1
}
// source by javascript-array.com/guides/javascript_faq/
//Internet Explorer 4+, Mozilla/Gecko/Firefox
function getCaretPos(obj)
{
obj.focus();
if(obj.selectionStart) return obj.selectionStart; //Gecko
else if (document.selection) //Internet Explorer
{
var sel = document.selection.createRange();
var clone = sel.duplicate();
sel.collapse(true);
clone.moveToElementText(obj);
clone.setEndPoint('EndToEnd', sel);
return clone.text.length;
}
return 0;
}
PHP function get first and latest character from string
// for earlier version PHP can use mb_strlen, mb_substr if use
// diacritical accent $str = 'ěščřžýáíé';
function startsWith($haystack, $needle)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
function endsWith($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}
return (substr($haystack, -$length) === $needle);
}
Date: 11.06.2020 - 20:10Editace: 18 10 2016
Počet článků v kategorii: 77
Url:javascript-browser-detection