I have an aspx page with JS calling window.location.reload(true) to force refresh a page when a function is called.
This appears to work a few times, with the page reloading as expected, but gets to a scenario where the function is called (i.e. alert in the function is visible) but the reload does not occur. I've also tried setting window.location with the same outcome - it works 2 or 3 times then fails.
This does not occur in Firefox (16), but is happening in different versions of IE (7 & 9)
Using Fiddler to monitor the browser traffic, all is as expected when the reload is working, but there is no traffic reported when the reload stops, suggesting the browser is not sending the request to the server? The IE window does go blank with the loading spinner spinning, but eventually IE displays the error page:
Internet Explorer cannot display the webpage
Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.
This appears to lock the browser. Trying to hit another website results in the same output in Fiddler (nothing). Opening a new IE window means I am able to hit the site with no problems.
This was initially causing a problem updating UpdatePanels via __doPostBack so this JS reload of the page was seen as a quick workaround, but this does not seem to be the case.
I would tend to think this is server related, but I have been unable to replicate the issue in Firefox. This does however unfortunately have to work in IE.
Any ideas much appreciated!
JS snippet below (though this is pretty simple stuff)
function ReloadWindow() {
alert(window.location); // Can see this alert, even when page fails to reload
window.location.reload(true);
}
Related
I have one page which takes some time to load in asp.net website. It works with all Android OS, all MAC OS, all iOS except iOS with version 10.0.0.2 with safari browser
When I am trying to load same page with safari in iOS 10.0.0.2, it throws 'safari could not open the page because the server stopped responding'.
I know the reason for this error is, my page is taking time. But my page is already optimized and it has so many things, that's why it is taking time.
I want to prevent my page from this error in 10.0.0.2.
I tried all the possible ways to solve this issue like :
Clear cookie and browsing data
Added 8.8.8.8 to DNS server
Airplane mode on-off
iPhone restart
But nothing helps.
Please help me to figure out this issue.
I found that iOS 10.0.0.2 has default timeout approx 1 minute. My page was taking more than 1 minute to load. That's why safari assumed that server is not responding and it was throwing that message.
I did not get any setting or anything to extend timeout limit of safari. At the end I optimized my code.
I am using telerik rad grid in my page and its MasterTableView's property named 'HierarchyLoadMode' was set as 'client'. I changed it to 'ServerOnDemand'.
That solved my issue by reducing page load time.
As
1) 'Client' loads grid data at the time of page load.
2) 'ServerOnDemand' loads grid data at the time of grid expanding
My page load time has been reduced and safari stopped throwing message.
If you are using telerik rad grid, I hope this will help you.
Does anyone know a way, via JavaScript, that I can either clear Safari's bfcache, or force it to reload rather that used a cached version of a page?
I have a web application that is running tests, and there is JavaScript which monitors a countdown (a timeout):
timeoutId = window.setInterval(function () {
timeoutRemaining--;
if (timeoutRemaining <= 0) {
location.href = myTimeoutLocation;
}
}, timeoutInterval);
This all works fine until I get to myTimeoutLocation. The behavior is that, if a user clicks the back button, the test should continue. However, when navigating back, I find that IE and Chrome reload the page, but Firefox and Safari are showing the cached page. I need to make sure that a cached page is NEVER shown. I can fix this problem in Firefox by adding:
window.onunload = function () { };
to my script, but that hasn't worked in Safari since Safari 5.x (as far as I can tell). I found another solution:
window.addEventListener("pageshow", function(evt){
if(evt.persisted){
setTimeout(function(){
window.location.reload();
},10);
}
}, false);
This worked to an extent... The problem I have now is that even with the above code, I am receiving a dialog box: ... which I'm apparently not allowed to embed. The dialog says that in order to display the page, information must be sent to the server, with the appropriate confirm or deny buttons. I did try setting forceGet to true, but that did not solve the problem with the dialog appearing. I should mention that clicking Resend has the desired effect.
Non-embedded image of dialog
And yes, I realize the image is of Firefox, not Safari.
In case it makes any difference (even though this is a JavaScript question), the site is coded in .NET/MVC4 and is hosted in IIS.
Thank you in advance for any help/thoughts/information/pointers in the right direction.
since a few days there seems to be a problem with a audio player script (flash + javascript) on one of our pages that NEVER occured before and I changed absolutely nothing in the code (it has worked for a few years now) that could cause this issue.
We bought the audio player script a few years ago, and again, until a few days ago, it worked perfectly.
The error also behaves very strange. Let me explain...:
The page is www.imatunes.de . You can see these small audio players on each article there.
Feel free to check out the code, got nothing to hide there.
My coworkers told me, that suddenly nothing happened if they clicked on the "Play" buttons. Normally, the script should start the flash player, which plays an audio file.
Now comes the "somehow" strange part:
My coworkers are all using Google Chrome. When they open the page in Chrome and click on a "Play" button, the JavaScript console throws the following error:
"Error on calling method on NPObject".
Googling that error says it has to do something with actionscript, cross-domain policies and such. But the error will get stranger...:
I'm using Firefox, and there it works FLAWLESS. But it also works on MY Google Chrome flawless, so it's very hard to debug (that's why I'm here to ask).
My coworkers also tried it on their home PCs, also running Google Chrome and such, and it also doesn't work there.
Now comes the "very" strange part:
When they get this error and reload the page via the browser controls (F5 or the reload button), it still won't work.
But if they browse around the page or just click on the logo in the header (which basically takes them to the home page again), the script magically works.
And on every other page except for the home page, it will work on first try.
As I said before, this started a few days ago - before that, everything worked just fine. And I really didn't change anything in the code.
So regarding the fact that it works after they browse around the page and return to the home page, it somehow seems like some sort of caching error.
I really don't know how I could debug this, or what to do.
Thank your for every possible help in advance!
I have a website that uses a long-polling comet connection. The connection needs to be setup on/after page load.
Despite my efforts to prevent it, many browsers consider the long-poll request to be part of the page loading mechanism, thus keeping the page in a 'loading' phase. In Safari this results in the progress bar (behind the url field) to not complete. In Chrome the favicon is shown as a spinning loading icon. Even more problematic is mobile safari on iphone, that does not allow hiding the url field while 'loading'. Mobile android has similar issues on some devices.
All in all, the behavior is difficult to reproduce and seems to be dependent on browser/platform/connection speed/etc. Right now, my code initiates the long polling 10msecs after the window.onLoad trigger. This seems to work well often, but not always. I suspect it may have something to do with loading some external (image/javascript) resources, yet one would say the onLoad event is fired after these are completely loaded.
Anyone some pointers on how to force these browsers into considering my page as loaded? Ideally, one could somehow mark an xmlhttprequest as comet-like, but this is no feature :).
I've been having the same issue and found that if you allow the page to exit its onload handler before issuing your long polling ajax request, everything works fine and the page does not go back into a loading state.
So for example, what usually would be
$(document).ready(function() { $.ajax(...); });
would become
$(document).ready(function() setTimeout(function() { $.ajax(...); }, 0); });
In the particular case of WebKit, I believe that $(document).ready is a synonym for window.onload. So that's why it matters.
This worked for me on iPad1,1 with iOS 5.
We have been successful removing the "loading" indicator in Safari 5.1.5 with ajax long polling requests. Chrome unfortunately still consistently shows the loading indicator. For chrome, our team has chosen to simply change the css cursor value on the entire body element (ex: crosshair or a custom cursor) - a terrible "hack" - but at least the user won't see the loading mouse cursor while they are on the system.
I've written a Greasemonkey javascript that works fine in NinjaKit the new Safari userscript manager, but when I try and compile the same script using the Safari 5 extension builder I get some very weird behavior.
The script gives the user an options editing screen, when you click the save button, the script saves the users preferences as a JSON packet via the HTML5 localstorage API, the script then closes the options screen and reloads the page, on the page reload, the script should reload the preferences from the JSON in localstorage, and the script should act on the new preferences to display the page the way the user wants it according to the settings they made.
The problem I am seeing is when I run it as an extension, when I click the save button, the script reloads the page, but when the page is reloaded the changes the user made to the settings do not get applied to the page. the weird part is, if I then manually reload the page again via the browsers refresh button, the changes the user made in the settings do all of a sudden become apparent. so obviously the data has been saved to the localstorage, but for some reason when the page reloads for the first time, it's somehow being reloaded from a cached file, and only on the second manual reload, is the new page displayed correctly. I can't understand why this works as a plain userscript in ninjakit, and also actually works in Firefox, Opera and Google chrome, it just wont work as an extension in safari, its soooo annoying. I've tried lots of ways to make sure that Safari 5 doesn't reload a cached page, e.g adding extra parameters to the URL, but I just can't get it to work, without having to reload the page twice.
BTW I'm not using the native safari extension settings system as I want the script to be cross browser compatible, so that's why I'm saving the settings to localstorage.
Has anyone else witnessed this behavior? Or got any clues how to fix this? It's driving me mental...
i managed to solve the problem though i didnt figure out exactly what was causing it.
i got the script working by adding it as an "end script" rather than a "start script" in the extension builder, it all seems to work fine now. phew!