I want the scrollbar to be positioned on top by default as soon as I launch the page.But the below code works fine in chrome but not in IE11.
If I try to debug the script, the scrollbar is positioned on top.
$(document).ready(function () {
window.scrollTo(0,0);
}
I tried different solution online such as
$(window).scroll().scrollTop(0);
document.body.scrollTop(0);
But nothing worked in IE.Kindly help me
Though this is a very old question, but updating here for someone looking for a solution.
Try using:
element.scrollTop = 0;
This should work on all browsers.
Try using
$('body,html').scroll().scrollTop(0);
or
$('body,html').animate({scrollTop:0});
Related
I was trying to use Visibility API, but it is not working for a child. The minimal example to reproduce:
<script>
document.onvisibilitychange = () => {
console.log(document.visibilityState);
}
if (!window.opener) {
window.open(window.location.href, '_blank');
}
</script>
After that, the parent window still prints "visible"-"hidden", but child prints "hidden" once only on refresh.
It works fine in the latest Opera browser, but not in the Chrome
To be honest, when I came to this minimal reproduce, I'm stuck and have no idea where to dig. Any ideas what could be wrong?
I also stumbled over this issue. I think that this bug was introduced in Chrome 84. I testet it with version 83 and it worked as expected. The current Canary-Build (Version 86) is also working.
I'm loading my site into an iFrame that's on another site. I'd like to scroll to the top of an element within that iFrame. I'm using the Javascript code below:
document.getElementById("cart-wrapper").scrollIntoView({ behavior: 'auto' });
This works perfectly on desktop browsers, however it doesn't work at all on iOS mobile (I've tested Safari and Chrome). I've tried the smooth scroll polyfill (https://github.com/iamdustan/smoothscroll) but that doesn't work either (I've basically included <script type="text/javascript" src="/js/smoothscroll.js"></script>) )
Any solutions? Thanks
Few days back , I was also facing this issue. I fixed it with iScroll
I tried iScroll
I would be able to help you, if you need any
I am calling this javascript on page load
document.body.scrollTop = document.documentElement.scrollTop = 0;
I want html page starts from top when loaded, above javascript working fine for chrome, safari(macbook) but not working for safari on iphone,
can anybody suggest workaround in javascript only.
Posting this here for future visitors from Google.
This same error occured to me... The problem was just one CSS rule on body element.
overflow-x: hidden
If this CSS rule exists, remove it and scrollTop should work on mobile Safari.
As I tested this before, there are problems rendering on ios, but it also depends on the version of the OS for example, for an iPad pro, there is no problem! But on iPad air you there isn't much to do! so what you can do is to make your code compatible like:
document.scrollingElement.scrollTop
it should give you the right solution.
I am having an issue with Internet Explorer 10 not properly registering the location of the mouse on the <canvas> element if it is not up against the top of the page. Open up IE10 and look at the links below.
The problem:
Click on this link and try dragging the nodes of the graph around:
http://ffi-server.no-ip.biz:257/test/good.html
Now, try the same thing on this page: http://ffi-server.no-ip.biz:257/test/bad.html
Interestingly, IE9 does not have this issue, and adding a <meta> tag to tell IE10 to render the page as IE9 does not solve this issue.
Possible solution?
I think I have found the problematic line of code, I just can't figure out how to correct it. Look at line 3044 in: http://pastebin.com/82GJBiEB
I just don't know how to correct it. I believe that IE10 is reporting a different e.pageY value than browsers which are working correctly. You can verify that by clicking on different areas of the canvas on this page: http://ffi-server.no-ip.biz:257/test/alert.html and see the reported values in IE10 and, say. Chrome.
Could anyone suggest a way to correct this issue?
Thank you for your time!
Try e.layerX, and e.layerY. I had a similar issue, and this fixed it.
I have a flash menu on a site. The menu works fine in all browsers EXCEPT IE9. It looks like this javascript file is not loading:
<script type="text/javascript" src="scripts/ActiveContentDropDownWide.js"></script>
In IE9 it just displays BUTTON1, BUTTON2 etc but in all other browsers it displays the complete menu. This is what happens when the ActiveContentDropDownWide.js script is removed which is why it seems to be a problem with that script and IE9. But I could be wrong?
Any ideas would be greatly appreciated.
Try doing a Fiddler capture with IE9 and FF. Then, compare the 2 captures using Fiddler's Diff feature.
It is seems to me that the menu is hiding behind the content
maybe it is z-index problem if the flash menu inside a div ,give it high z-index number or google for ie9 z-index problem.
The javascript file that powers some of the menu needed to be updated with a new version that supports IE9. Once I updated it, the menu worked fine in IE9. Thanks.