I wanted to hide header only in mobile applications, but have to show header in all mobile browsers as same as in desktop browsers. how can i recognize mobile application through css media queries or in java script or else is there any choice to find mobile application??
can you please help me i can i hide html header only on mobile applications ??
i have tried below java script code but i did not get result
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isIE = /*#cc_on!#*/false || !!document.documentMode;
var isEdge = !isIE && !!window.StyleMedia;
var isChrome = !!window.chrome && !!window.chrome.webstore;
var isBlink = (isChrome || isOpera) && !!window.CSS;
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
var mobOpera = (navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1;
var mobChrome = navigator.userAgent.indexOf("Chrome") != -1;
var mobSafari = navigator.userAgent.indexOf("Safari") != -1;
var mobFirefox = navigator.userAgent.indexOf("Firefox") != -1;
var mobIe = (navigator.userAgent.indexOf("MSIE") != -1) || (!!document.documentMode == true);
var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));
if (isOpera || isFirefox || isSafari || isIE || isEdge || isChrome || isBlink) {
$(".navbar-fixed-top").css("display", "block");
}
else if (mobOpera || mobChrome || mobSafari || mobFirefox || mobIe) {
$(".navbar-fixed-top").css("display", "block");
}
else if(is_android || isMobile.any()){
$(".navbar-fixed-top").css("display", "block");
}
else
$(".navbar-fixed-top").css("display", "none");
Related
In cognos 10.2, the js script below was working well for hide/show functionalities, but after migrating to cognos 11.0.12, it's not working fine.
I replaced
node.onpropertychange=ShowOrHide; with node.addEventListener("change", function(){ShowOrHide();}); and it only worked when I changed the radio button values, not on running the report.
The js script is as below:
<script type="text/javascript">
try
{
var cntlName;
var eleTarget1 = document.getElementById('DateRadPrompt');
var node_listDB = eleTarget1.getElementsByTagName('input');
var eleTarget11 = document.getElementById('divGreyOut');
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) {
fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}
var list = fW._oLstChoicestodate;
for (var i = 0; i < node_listDB.length; i++)
{
var node = node_listDB[i];
if (node.getAttribute('type') == 'radio')
{
node.addEventListener("change", function(){ShowOrHide();});
}
}
function ShowOrHide()
{
console.log('welcomeShowOrHide');
var DateRadPrompt = document.getElementById('DateRadPrompt');
var eleSource11 = event.srcElement;
if(eleSource11.checked)
{
if (eleSource11.value == 'most_qtr'|| eleSource11.value == 'most_mon1'|| eleSource11.value == 'most_mon2' || eleSource11.value == 'most_mon3' || eleSource11.value == 'cal_prompt' || eleSource11.value == 'most_fsc_yr' || eleSource11.value == 'most_mon12' || eleSource11.value == 'most_qtr4' || eleSource11.value == 'cal_prompt1')
{
eleTarget11.style.display ='none';
}
else
{
eleTarget11.style.display ='block';
}
}
}
list.remove(1);
list.remove(0);
list.removeAttribute("hasLabel");
for (var i=0; i<=node_listDB.length;1++)
{
var nodeDB = node_listDB[i];
if(nodeDB.options[i].selected == true)
{
null
}
else
{
nodeDB.options[0].selected = true
}
}
if (list.options.length==1)
{
eleTarget1.style.display='none';
}
canSubmitPrompt();
}
catch(e)
{
}
</script>`
I'm trying to make the input takes only the value 99.999. I don't want to use MaxLength because it would not calculate the length of the decimal digits. I don't want to use any other functions that erase when it doesn't match a specific regex. I want it to stop it in the input.
function IsCurrencyNoMinus1 (e, thisobj, min, max) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode == 44) || (keyCode == 46) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode))
var inStr = $(thisobj).val();
if (ret && (keyCode == 45) && ((thisobj.selectionStart != 0) || (inStr.indexOf('-') != -1)))
ret = false;
if (ret && (keyCode == 46) && (inStr != '' && inStr.indexOf('.') != -1) && !(Math.abs(thisobj.selectionStart - thisobj.selectionEnd) == inStr.length)) {
ret = false;
}
var dotPos = (inStr.indexOf('.') != -1) ? inStr.indexOf('.') : inStr.length;
inStr = inStr.replace(/\,/g, '');
var parts = inStr.split('.');
var maxParts = max.toString().split('.');
if (ret && (inStr != '' && (keyCode >= 48 && keyCode <= 57))) {
if ((parts[0].length >= maxParts[0].length) && ((thisobj.selectionStart - thisobj.selectionEnd) == 0)
&& (thisobj.selectionStart <= dotPos)) {
ret = false;
}
if (ret && (parts[1] != undefined && parts[1].length >= 2) && ((thisobj.selectionStart - thisobj.selectionEnd) == 0)
&& (thisobj.selectionStart > dotPos) && (thisobj.selectionStart <= dotPos + 3))
ret = false;
var firstPos = thisobj.selectionStart < thisobj.selectionEnd ? thisobj.selectionStart : thisobj.selectionEnd;
if (ret && (parts[0].length >= maxParts[0].length) && (parts[1] != undefined && parts[1].length >= 1)
&& ((dotPos - firstPos == 0 && Math.abs(thisobj.selectionStart - thisobj.selectionEnd) < 4)
|| (dotPos - firstPos == 1 && (Math.abs(thisobj.selectionStart - thisobj.selectionEnd) >= 2 && Math.abs(thisobj.selectionStart - thisobj.selectionEnd) < 4))))
ret = false;
}
if (Number(inStr) > max) {
thisobj.value = '';
ret = true;
}
if (Number(inStr) < min) {
thisobj.value = '';
ret = true;
}
// var re = new RegExp(/^\(?-?[0-9]{0,12}(\.[0-9]{0,2})?\)?$/)
// if (!re.test(inStr)) {
// thisobj.value = ""
// }
return ret
}
I found the solution! Please check the code below in case someone needs it.
function Format3DigitDecimal(e, thisobj, min, max)
{
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode
var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode == 44) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode))
var inStr = $(thisobj).val()
inStr = inStr.replace(/\,/g, '')
if (ret && (inStr != '' && (keyCode >= 48 && keyCode <= 57)))
{
if ((inStr.length >= max.toString().length) && ((thisobj.selectionStart - thisobj.selectionEnd) == 0))
{
ret = false
}
}
if (ret && (inStr != '' && (keyCode >= 48 && keyCode <= 57)))
{
if ((inStr.length == 2) && ((thisobj.selectionStart - thisobj.selectionEnd) == 0))
{
ret = false
}
}
return ret
}
I'm still learning jQuery, and I'm trying to figure out why this script isn't working.
The goal is to turn off Stellar.js parallax for mobile, which I've done by detecting a specific CSS class. I'm also trying to turn it off on Safari and IE because of jumpy performance when using a mousewheel to scroll. Any assistance troubleshooting, since I know the code is syntatically valid, would be awesome.
(It's wrapped in the "jQuery(document).ready(function($)" to function well in WordPress.)
jQuery(document).ready(function($) {
$(document).ready(function() {
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
//Function to the css rule
function checkSize(){
if ($(".parallax").css("background-attachment") == "inherit" ){
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: false,
});
});
}
if ($(".parallax").css("background-attachment") == "fixed" ){
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: true,
});
});
}
}
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*#cc_on!#*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
// check if Safari or IE and disable parallax
if(!isSafari || !isIE)
{
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: false,
});
}
});
Update: I cleaned this up, but now I'm getting an error when I inspect that isFirefox, isChrome, etc., are not defined. Is that because I'm calling the variables incorrectly?
jQuery(document).ready(function($) {
$(document).ready(function() {
// hella browser checks
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*#cc_on!#*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
//Function to the css rule
function checkSize(){
if ($(".parallax").css("background-attachment") == "inherit" ){
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: false,
});
});
}
if ( ($(".parallax").css("background-attachment") == "fixed" ) && (!isFirefox || !isChrome || !isBlink || !isOpera) ) {
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: true,
});
});
}
}
});
This resolves it. Turns out I had to do it within the first function and I needed to call the variables within the screen size check. I hope this is helpful to someone else!
jQuery(document).ready(function($) {
$(document).ready(function() {
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
// hella browser checks
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*#cc_on!#*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
//Function to the css rule
function checkSize(){
if ($(".parallax").css("background-attachment") == "inherit" ){
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: false,
});
});
}
if ( ($(".parallax").css("background-attachment") == "fixed" ) && (isFirefox || isChrome || isBlink || isOpera) ) {
$(function () {
$.stellar({
horizontalScrolling: false,
responsive: true,
parallaxBackgrounds: true,
});
});
}
}
});
Morning
I have these functions below using "navigator" to retrieve various information about the operating system browser and device type. I would like to know I can get the IP address ,version of the browser and I would like to know if its possible to get the device type whether its a desktop , phone or tablet . This is what I have so far
function detectmob() {
//alert(BrowserDetect.browser);
var os = navigator.platform ;
if (navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
) {
return true;
}
else {
return false;
}
}
function detectBroswer() {
if ((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1) {
alert('Opera');
}
else if (navigator.userAgent.indexOf("Chrome") != -1) {
alert('Chrome');
}
else if (navigator.userAgent.indexOf("Safari") != -1) {
alert('Safari');
}
else if (navigator.userAgent.indexOf("Firefox") != -1) {
alert('Firefox');
}
else if ((navigator.userAgent.indexOf("MSIE") != -1) || (!!document.documentMode == true)) //IF IE > 10
{
alert('IE');
}
else {
alert('unknown');
}
}
I don't know how to get the IP address of logged in user using javascript,
but here is what I've found on how you could check what version of browser user is using.
navigator.sayswho = (function(){
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return "IE " + (tem[1] || "");
}
if(M[1] === "Chrome") {
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem != null)
return tem.slice(1).join(" ").replace("OPR", "OPERA");
}
M = M[2] ? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if( (tem= ua.match(/version\/(\d+)/i))!= null)
M.splice(1, 1, tem[1] );
return M.join(" ");
})();
alert(navigator.sayswho)
I want a simple function for toggling full screen. Here is what I've written:
function toggleFullScreen() {
var elem = document.documentElement,
request = elem.requestFullscreen || elem.msRequestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullscreen,
exit = document.exitFullscreen || document.msExitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen;
if (!document.fullscreenElement && !document.msFullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {
request.call(elem);
} else {
exit.call(document);
}
}
Any better or simple solution?
Thanks.