There are a couple of pages that have started to load incorrectly on most browsers on my computer:
https://www.appfrontier.com/documentation/
https://login.live.com/
When these pages load I see blank space and overlapping text, which seems to be the result of JavaScript not running properly on the page.
This happens in Chrome, FireFox, Opera, IE, and Edge. I am using Windows 10.
However, when I load these same pages in Brave browser, they load fine and everything works.
This issue is specific to one computer... On my other computer the pages load fine on all browsers.
I tried to figure out the problem and notice that when chrome requests for some HTML/JavaScript files, an error occurs when evaluating window.navigator.userAgent. For example, the browser should retrieve the following .js file:
function isIE() {
var ua = window.navigator.userAgent;
// do stuff depending on the browser
}
However, instead, the below code is returned as the response to retrieve the .js file:
function isIE() {
var ua = window.'Mozilla/5.0 (PlayStation 4 3.11) AppleWebKit/537.73 (KHTML, like Gecko)'
// do stuff depending on the browser
}
Because of this, an error occurs "Uncaught SyntaxError: Unexpected string"
I think something is wrong with my computer but I have no idea what. I tried uninstalling and reinstalling each browser but that does not work. Any suggestions are appreciated.
Found out the problem. It was Iolo System Mechanic. Looking back I feel stupid for using the product because it said that it was actively "cleaning up" windows and internet junk files. I'm guessing it deleted something that broke JavaScript loading for pages that use window.navigator.userAgent.
Just a bit of background - I was updating a legacy feature that is all javascript as there was new functionality being added to our web app that the legacy feature had to interact with.
While testing this update we noticed that there was an issue when moving from page to page within the web app - the legacy feature is supposed to follow you if it has been activated.
Basically the data from the activated feature wasn't being retained. There is some code in there that was supposed to do this. After some investigation it was discovered that it is working as expected in IE/Edge and Firefox but the exit code is not getting executed in Google Chrome and Safari.
This might explain why the business wasn't aware of the issue but it's been confirmed that the issue is also in the live site so hasn't been recently introduced as I believe most of the users would be on IE.
The code that was managing the exit functionality was as follows:
if(window.onpagehide || window.onpagehide === null){
window.addEventListener("pagehide", storeDataFunction, false);
} else {
window.addEventListener("unload", storeDataFunction, false);
}
With the above code the logic within the storeDataFunction doesn't even execute when you attempt to leave the page.
After some browsing on here and other forums I have updated the above to:
window.onbeforeunload = storeDataFunction;
and made storeDataFunction return null.
This appears to be slightly better in that the storeDataFunction is getting executed when moving pages but deep within it there is an ajax POST to a controller in our web app that stores the data necessary to check if the feature is active and what it has done and this ajax request does not get executed.
Again this is only on Chrome and Safari and works fine on IE and Firefox.
So what I'm looking for is a steer. Am I heading down the wrong path using onbeforeunload for what we want to achieve here? Or was the original use of pagehide/unload more appropriate?
Are both of those incorrect and there is a better way of doing it?
This feature was developed about 7 years ago so I'm not even sure if it ever worked on Chrome or if it did at time of development and some more recent updates in Chrome changed they way it handles page termination.
Thanks in advance.
Looks like Google have updated Chrome to stop XHR during page dismissal.
https://www.chromestatus.com/feature/4664843055398912
I'm having issue redirecting a webpage on all browsers. I created a custom page for a client about a year back on SHOPIFY and now the redirect function no longer works.
I was originally using document.location.href = "/cart" and all worked well. But I recieved a call from him today saying the page wont redirect anymore on his IPhone.
I changed it to window.top.location.href, this fixed it for most browsers except safari. I understand that the best way for this to work on all browsers is the document version. But that seems to have been out dated this year.
setTimeout(function(){ document.location.href = '/cart';},1000);
Checking the user agent of the browser and if it's safari we can do a different tailored version of a redirect, just haven't found out how to do this on the new safari yet.
#stanislav seems to have the same issue from this link, I suspect we will start to see the number of people with this issue growing.
Why isnt window.location.href= not forwarding to page using Safari?
Thanks to all for the input and suggestions, hoping to get the resolved soon.
try upgrade , Safari version 14 fixed this bug.
Okey!
So I am running a Spring MVC Thymeleaf project. I have a simple alert which should show each time when I start my site. This works perfectly except for when I try it with Explorer (IE11). Tried on Chrome, Edge, Firefox.
Its a very simple "alert ("hello")" in document.ready
I tried to "allow javascript" on internet explorer. It still doesnt work, i tried if javascript is allowed by going to different sites.
Hmmm what more could be more relevant.
I tried to ad localhost to "trusted" sites, doesnt work.
I tried the code on jfiddle and sites like this, works a treat.
I have localhost so the site is not "secure" obv, this is not the problem because I have tried the code on the host aswel. I have googled and tried but I cant do more than I've done... Nothing seems to work.
Anyone out there with the same problem? Thanks.
You can try by checking following.
Ensure your console doesn't show any errors and correct them if there are any.
Be sure you didn't disable browser prompts on IE
Try using window.alert() - it's possible (though improbable) that another alert() is conflicting with window's.
If you have console support, try console.log(alert); and see what it says. It should be something like:
function alert() {
[native code]
}
I'm trying to figure out why something with Javascript isn't working inside of a UIWebView. To my knowledge, there is no way to set a breakpoint inside of XCode for a js file. No problemo, I'll just go back to 2004 and use alert statemen-- oh wait they don't seem to work inside of a UIWebView either!
The only thing I could think of is by exporting my HTML And JS files to my desktop and then just doing my debugging inside of Safari. And that works! But of course, the bug I'm fighting with in the UIWebView doesn't occur in Safari.
Are there any other ways for debugging inside of a UIWebView, or any tricks that I can use akin to using the old-school alert method?
If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:
Open the application in the simulator (or your device in XCode >= 4.5.x).
Open Safari (go to Preferences -> Advanced and make sure "Show Develop Menu in Menubar" is on.
From the Menu-bar (of Safari) select Develop -> iPhone Simulator -> [your webview page].
That's it !
This query tops google, so worth linking to the remoteInspector hidden in iOS5 - by far the best way found so far to debug your UIWebViews - just conditional compile out before you send to Apple.
alert() certainly works for me.
However, you can also do lots of other things, like make your own DHTML alert that pops up in a layer. This can be nice because you can do multiple alerts to a single div, without stopping your app. You should also be able to write a stack trace to it (the stack trace is in the exception object, and you can always throw your own exceptions).
Alternatively, if running on the simulator your custom "alert()" could call into objective C, and display the string in the iPhone simulator's console window:
document.location.href = "http://debugger/" +
encodeURIComponent(outputString);
and on the objective C side:
//--------------------------------------------------------------------
- (BOOL)webView:(UIWebView*)webView
shouldStartLoadWithRequest: (NSURLRequest*)req
navigationType:(UIWebViewNavigationType)navigationType {
if ([[[req URL] host] isEqualToString:#"debugger"]){
// do stuff with [[req URL] path]
}
}
That said, I have an app that is heavy on the UiWebView / javascript stuff, and I tend to do most javascript dev in Chrome (simulating what is necessary from the iPhone environment)
I get the awesome way to debug UIWebView Or
SFSafariViewController.
I hope It will Help.
Step 1:
Open Safari VC In Your Mac (hahaha Don't make your face, If I am saying in your Macbook just follow this my steps)
Step2: Go at Safari preferences And Click on Advance.
You will Get this setting on your MacBook Screen.
Now enable the Show to develop menu in menu bar.
Now Your All work is done.
Are you thinking I am kidding :P :P no man...
Step3: Run your application in Device or Simulator. (Don’t Think Just run )
And go in your application where you are opening your Webview or SFSafariViewController.
Till now you did not understand I know. Be cool and see my next step.
Step4: Open Safari In your MacBook and Click on Develop Option from the Menu bar.
Did you get something your MacBook, iPad/ iPhone is Displaying Right?????
Step5: Its Done. click your device and click on URL New popup will come out like This.
Step6: what are you looking now its over here all the steps.
Now debug your Webpage on this console.
Be happy and enjoy your day while doing coding With a cup of tea or
Coffee.
IMP: Don't forget to enable See Below Image
I haven't tried this yet, but take a look at this Weinre
Looks very promising.
This is an old question. But I'll still like to share my two cents.
I have been using jsconsole.com for remote debugging. It's easy. Just include a script tag and use console logs to debug by printing. This can also be used for debugging on a real device.
Old question, but I think I found the best solution, in my case you need to debug uiwebview, but I had no access to the IOS app and only to the html content and I had to view some JS logs, I added the following code to load the light firebug JS and show it automatically:
calling it from JS
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://getfirebug.com/firebug-lite-debug.js';
document.head.appendChild(script);
or load it from html
<script type="text/javascript" src="https://getfirebug.com/firebug-lite-debug.js"></script>
You can set up a system like that used in PhoneGap to send messages from JavaScript to Objective-C and log from there. In a nutshell, they are setting document.location with a custom scheme and blocking that scheme in the delegate callback.
You can take advantage of the fact that a UIWebView is most of the delegates for a WebView. WebKit is technically undocumented for iPhone, but mostly the same as specified in the desktop WebKit headers, possibly including the WebScriptObject. I use this for debugging, but be sure to strip this code out before submitting to Apple.
To get a WebView from a UIWebView, implement a delegate method like -(void) webView:(id)inWebView didFinishLoadForFrame:(id)inWebFrame in a subclass of UIWebView. Call super if you use that one.