I have seen this question which is similar except it does not specify the browser and OS. I have also seen this question which describes the same issue for Chrome running on iPhone (I have tried the accepted answer, which suggests using JavaScript instead of jQuery, and it made no difference).
What I want to do is to show/hide pagination buttons depending on the number of documents in the search result. This is the code:
function showHidePagination(totalNoOfDocuments) {
var paginationContainer = document.getElementById('paginationContainer');
if (totalNoOfDocuments <= pageSize) {
paginationContainer.classList.add('d-none');
//$('#paginationContainer').addClass('d-none'); // <-- this did not work either
} else {
paginationContainer.classList.remove('d-none');
//$('#paginationContainer').removeClass('d-none'); // <-- this did not work either
}
}
When user clicks on Search button, an Ajax request is send to the server, the new results are fetched and then I call showHidePagination() and pass the total number of documents in the result. The function should hide the pagination if the total number of documents are less than pageSize (which is a constant variable).
The above code works in desktop and it does not work on Chrome running on Android. I have also seen this document which suggests removeClass works but addClass does not work... it suggests solving issue by negating the logic and using removeClass but I cannot see how to toggle d-none class this way...
I am not able to understand why is this issue happening? And how should I resolve this?
Related
I wrote the following code for debugging puposes:
(function () {
"use strict";
// The initialize function is run each time the page is loaded.
Office.initialize = function (reason) {
$(document).ready(function () {
// Use this to check whether the API is supported in the Word client.
if (Office.context.requirements.isSetSupported('WordApi', 1.1)) {
// Do something that is only available via the new APIs
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, onSelectionChanged);
}
else {
// Just letting you know that this code will not work with your version of Word.
$('#status').html('This code requires WordApi 1.1 or greater.');
}
});
};
var c = 1;
function onSelectionChanged(eventArgs) {
c++;
$('#status').html('onSelectionChanged() call '+c+);
}
})();
This code only sometimes reacts to changes. Sometimes reeaaly slow. Sometimes (I guess, if it is too slow and there have been multiple changes in between, it does not recognize them und prints onSelectionChanged() call 4 after a while, even though, there have been many more changes.
Other times, if I close Word, and open it again, it just works as a charm. Then I close it and open it again, and again, it fails - It is completely inconsistant. Thereby this feature is effectively not usable.
I tested this on different machines, different versions of Windows and it occures independend of the utilization of the system.
Any ideas?
Unfortunately I was not able to repro your issue. The event works quite consistently.
Its not related but is there a specific reason why you are checking the 1.1 requirement set? This event was shipped on the first release of the API so that's not needed.
If you can provide your build number and a sample document and video of whats going on we could investigate in more detail.
thanks!
I use adobe analytics and try to track links using this:
$(document).on('click', 'a', function() {
s.tl(this, 'e', 'link', null, 'navigate');
return false;
});
or
$("a").click(function() {
s.tl(this, 'e', 'link', null, 'navigate');
return false;
});
and when I tested it and click in a link in Chrome I receive for the first the status page canceled and using the second option in chrome everything works fine but in Firefox I receive status 0 GET (NS_BINDING_ABORTED).
Is there any workaround which could run without problem in all browsers or should I fix anything to the previous?
From here is the example I use using the second box as example
I found this solution:
https://marketing.adobe.com/developer/es/forum/general-topic-forum/custom-link-tracking-capturing-issue
Which proposes this as a work around:
<script language="javascript">
function pejTracking(linkname,url) {
var s=s_gi('myprodsuite');
s.tl(this,'o',linkname,null,navigate(url));
}
function navigate(url) {
window.location=url;
}
</script>
This really works!
Is it possible to make it to work with the JQuery document or a onclick function as I have at the start of my post and there is any need to have the onclick in every link?
This is common, and (probably) isn't a problem.
This error occurs because the link tracking image request is designed to let the browser proceed to the next page before waiting for a response from the Adobe data collection servers.
Adobe Reference: NS_Binding_Aborted in Packet Monitors
Update:
You commented:
Yes I have seen this but is it possible to fix it?
You are asking to "fix" this as if it's something that is broken.. my point is that it's not broken.
But if you insist on wanting to make sure this doesn't show up, you will need to do the solution you already posted in your question.
The jQuery equivalent would be to make use of event.preventDefault() and then update window.location after the s.tl call (in navigate callback) same as the non-jQuery solution.
You also asked:
And what about chrome?
What about it? This isn't browser-specific. It has to do with timing. Try it enough times in Chrome and you should see that NS_Binding_Aborted error in Chrome, too. Maybe. Depends on connection speed, current CPU resources, internet traffic in general, how the stars are aligned, etc. - you know, all the things that make requests and response happen later rather than sooner.
I have this tiny little script that I run inside Chrome using Tampermonkey and works great.
However, when I use it in Firefox with Greasemonkey, it shows up on the active list, meaning its matching the page but it doesn't actually execute the code. I know it has to be a simple something I am overlooking but its not hitting me.
var myVar=setInterval(function(){myTimer();},100);
function myStopFunction()
{
clearInterval(myVar);
}
function myTimer()
{
var p1 = "Login";
var p2 = "mode=login";
var x = document.body.innerHTML;
if (x.match(p1) && x.match(p2)){
document.documentURI = "/ucp.php?mode=login";
}
myStopFunction();
}
Script Logic/Function
I am using a timer to prevent the script from triggering over and over in a permanent loop.
It simply detects if I am logged into a phpBB forum or not, if not send me to the login page so I can log in.
I am using document URI so that the location of the original is preserved so upon login, it takes me right back to it.
Often phpBB when you log in, it will take you back to the index page so this preserves my original intent of going to the actual link.
This script works perfectly and as expected on Chrome using TM but on Firefox using GM it doesn't trigger, am I missing something here?
From the Firefox spec:
(document.documentURI)
Returns the document location as string. It is read-only per DOM4 specification.
And, indeed, the latest spec still specifies that this attribute must be read only.
If Chrome lets you write this property, then that is non-standard behavior and maybe a bug.
Use location.assign(), or location.replace(), or just programmatically click the login button -- which often preserves the target page.
If I take a database object (db) and open it with the command
var db = window.openDatabase("phr", "", "Cognovant PHR", 25000000);
// This should open whatever database is created, otherwise spawn one with a blank
// version number ("")
and then later do:
db.changeVersion(db.version, "2"); // Update database to version 2
console.log(db.version); //Should return "2", instead returns previous version of database
This code, line-for-line works flawlessly (almost better than I had hoped) on iOS, but constantly fails to change the database version on Android.
If there's some better way to do this, or some alternative way that needs done on Android, I would be greatly appreciative of the information.
This is actually pretty simple to solve.
Simply change the 2 argument version of db.changeVersion to the 3 argument version. Example:
db.changeVersion(db.version, "2", function () {console.log("foobar")});
And it will work.
This problem also occurs in Android 2.2.
09-28 07:15:14.954: E/Web Console(280): TYPE_MISMATCH_ERR: DOM Exception 17: The type of an object was incompatible with the expected type of the parameter associated to the object. at file:///android_asset/www/devbar/03%20db.js:158
The only solution I see is to workaround with my own version management.
Please go through below link, describes the way to implement the database Version control.
http://developer.apple.com/library/safari/#documentation/iphone/conceptual/safarijsdatabaseguide/UsingtheJavascriptDatabase/UsingtheJavascriptDatabase.html
i am able to do success operation with all 2.3.x devices, but with 4.x.x android device getting issue like 'unable to call method changeVersion' and saying method is undefined.
for time being i am using code as below,
if (db.changeVersion) {
db.changeVersion(oldVer, curVer, upgradeTableStructure, errorHandler, successDataHandler);
} else {
createTableStructure(db);//If Not exist for first time for 4.x.y devices
console.log('version changes not possible in this browser version.');
}
but this is not the right solution for the Current Problem, please suggest some solution.
I'm using the Prototype (and script.aculo.us) javascript library - since it's what comes with Rails "as standard" - and having a problem with the following snippet:
function show_hide_selects()
{
chkbox = document.getElementById('game_random_select')
seldiv = document.getElementById('card_selects')
if (chkbox.checked && seldiv.visible())
{
Effect.BlindUp('card_selects', {duration: 0.5})
Effect.BlindDown('random_options', {duration: 0.5})
}
else if (!chkbox.checked && !seldiv.visible())
{
Effect.BlindUp('random_options', {duration: 0.5})
Effect.BlindDown('card_selects', {duration: 0.75})
}
}
This snippet is fired onClick for the 'game_random_select' checkbox which controls whether the user wants to specify a list of card-names, or leave the server to make a random choice. It should hide the irrelevant set of form elements, and show the relevant set.
This works fine in FireFox, but doesn't work in Internet Explorer (tested IE 8). It throws an error "Object doesn't support this property or method" on one of the if-test lines; using the JS debugger indicates that it's seldiv.visible() that doesn't work.
How can I detect the visibility of the element in IE - surely Prototype should be completely compatible with IE? Or am I never going to be able to manage it with Prototype, and should switch to jQuery - which would obviously be Effort, since I'll need to get Rails to comply as well.
Huh. Sorted this myself, thanks to reading the API documentation and spotting something I wasn't doing.
seldiv.visible() doesn't work, but $('card_selects').visible() does.
You can try getStyle http://www.prototypejs.org/api/element/getStyle, it will return null if the element has a display property of none.