jquery ajax chat scrollbar chrome - javascript

this question is very similar to many other questions posted on stack overflow,I have found about a few solutions that I based my code on but no help with what I'm searching for on, Overstack , yelotofu and a few similar posts ... (This is kind of related to another question I've posted a few days ago but I'm pretty sure it's inactive by now since I got my answer so).
So I've basically created an ajax chat application and I want the scroll bar of a div to check if it's at the button and if it is show the message then scroll. I have found 3 main ways to do this(removed one of them because the basics of it were the same as the others)
either:
if($("#chatscreen")[0].scrollHeight - $("#chatscreen").scrollTop() == $("#chatscreen").outerHeight())
{
alert("work");
}
or
$("#chatscreen").scroll(function(){
if($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight())
{
alert("work");
}
});​
I have tested the first code on firefox, internet explorer and chrome, it worked great on firefox and internet explorer but not on chrome.
The only real difference between them is $("#chatscreen").scroll(function(){ which basically keeps executing the script when the scrollbar is being used and for some reason this worked while bugging all 3 browsers I have tried making them unusable.
And so I've been trying to find a good alternative that could work on both firefox, chrome and internet explorer.
Thank you for any help/advice you can provide.

I figured out why it wasn't working, on chrome
$("#chatscreen")[0].scrollHeight - $("#chatscreen").scrollTop() == $("#chatscreen").outerHeight()
was false, Still not sure why it works when we added the .scroll() but well the above equation needed to be changed by adding a -1 to the end result to make it work.
Writing this here because it might help someone some day...

Related

Lightbox2 Suddenly Not Working in Chrome

About a year ago, I posted here for the first time with a very similar issue: I had just created an image gallery for my art portfolio site, when it was failing in Chrome but performing fine in Microsoft Internet Explorer and Edge.
With some help from very kind (and very patient!) people here, I got Lightbox2 to work in Chrome. It was lovely-- until about a month ago.
Suddenly, only Edge understands the script and Lightbox2 runs fine--
But Chrome seems to have forgotten how to understand and run it.
My coding has not changed since that beginning success--
Could someone take a look and see if something needs to be changed or corrected?
LIVE SITE: art.juniebug.net/portfolio.html
Thank you very much!
I just had that problem myself. I found it worked in other browsers so I just went to Chrome preferences, under Advanced and clicked "Restore settings to their original defaults"
Fixed it.

skrollr mobile clicking on item returns error

I am using the skrollr plugin for parallax https://github.com/Prinzhorn/skrollr. I know it works fine on iPad 3 and iPhone 4S with version 6.1.3.
However, on an iPad 2 version 5.1.1 and several various Android devices, I have run into an issue where if I attempt to click on any link...or really anything at all...I get a message that says:
"JavaScript:Error undefined TypeError:'undefined' is not a function".
I isolated the issue to skrollr.js about line 649 initialElement.click();. If I remove that call, then the error no longer happens...except obviously I still can't click on anything.
Also, I know for sure that this is an error in the plugin itself because I tried clicking on things in the skrollr demo and get the same error http://prinzhorn.github.io/skrollr/.
Has anyone come upon a solution for this? I haven't seen it posted anywhere. Also I've already tried alternatives such as:
initialElement.mousedown('click');
initialElement.trigger('click');
initialElement.bind('click');
initialElement.live('click');
initialElement.delegate('click');
and all give the same exact error.
I find it strange that it doesn't occur in all devices, and the rest of the plugin seems to be working...so it's not an issue on where I'm importing it...heck even everything else attached to initialElement seems to be okay.
Any ideas?
Once again, I would give you a link to my site but can't due to disclosure agreement. But if you need snippets of code let me know.
Thanks for the help!! :)
Maybe give this a shot at line 644 - https://gist.github.com/JustinWUP/6032497
Changing the following on skrollr.js worked for me. [Added $() around the 'initialElement']
if(distance2 < 49) {
//It was a tap, click the element.
//initialElement.focus();
//initialElement.click();
$(initialElement).focus();
$(initialElement).click();
return;
}

Script error in ie7,ie8 and firefox 3.6

In a website that I am currently working on , I get a collection of data from back-end dynamically and populate to Jcarousel when the page loads. The site is working fine in chrome , ie9 and ff 21 but it throws script error which says "A script on this page is causing Internet Explorer to run slowly" . Has any one faced similar issue? Is it because the Jarousel cannot accommodate huge amount of data or is it some thing wrong with my code? I should also say that this issue is spasmodic !
I saw this post http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers but I already have so much of timers set in the page. Is there any other alternate solution?
Appreciate suggestions .Thanks in advance
Ie7 and 8 are crap. Their's no silver bullet to deal with this error, unless you do not exactly know what script/loop/ajax/wtf.. is causing the error. You need to debug that in depth in order to find out what's going on, sorry, no better advise.

DOM issues in IE

I've developed an application that I had tested in Chrome and Firefox but then upon testing in IE I noticed a few things weren't working quite as they should so I made a couple tweaks and everything seemed to be working as it should.
However, as if by some sort of magic when I was going through another round of testing in IE I started noticing that I was getting a lot of debugging errors that I had previously been getting.
They all seem to be to be DOM related with IE being unable to get the value of properties because the object is either null or undefined.
I was having none of these issues previously and I have absolutely no idea what might have changed to be causing this but does anyone have any experience of this sort of issue and have some suggestions as to how to resolve the issue?
I've had a look through all the different pages and functions I've been working on the last couple hours but can see nothing obvious that might be causing this.
Any help would be very much appreciated.
Thanks!
The latest versions of IE come with a pretty decent script debugger. If you press F12, a developer tools window will pop up. Click on the "Script" tab and start working your problem from there. Its not as robust or efficient as firebug or chrome's developer console, but its better than nothing and more often than not can get you pointed in the right direction when it comes to squishing IE bugs.

fb:loggin-button gets stuck [duplicate]

I am having problems getting Facebook login to work correctly in IE. The problem is intermittent. Usually, when it makes the call to FB.login, the popup appears but stays on an empty white page, XD proxy, and never runs the callback. Occasionally, the callback will run, but the window will not close - I think this may be the first time I try it after rebooting my machine (closing and opening the browser does not have the same effect).
You can see this problem on www.runescape.com/, yet with the same code on www.waroflegends.com/, the login seems to work correctly.
I have searched and found a lot of talk on the XD Proxy topic, but none of the solutions seem to work for me. I have tried adding a custom channel url and making sure the fb div is the first child of the body to no effect.
I've been experiencing the same issue in IE9, and it seemed to stem from upgrading to Flash Player 10. I'd lost hope in trying to fix it since finding an open bug at Facebook covering it. But Henson has posted an answer that fixed it for me. In the JavaScript in my site master I removed the lines
FB.UIServer.setLoadedNode = function (a, b) {
//HACK: http://bugs.developers.facebook.net/show_bug.cgi?id=20168
FB.UIServer._loadedNodes[a.id] = b;
};
and now it works. (N.B. I have not checked to see if the IE8 issue those lines were intended to overcome returns.) If that's not it take a look at some of the answers suggested in FB.login dialog does not close on Google Chrome
Try this right after FB.init:
if($.browser.msie || $.browser.opera) { // yes, this is jQuery :)
FB.XD._transport = 'fragment';
FB.XD.Fragment._channelUrl = yourChannelUrl;
}

Categories

Resources