Preload JavaScript in UIWebView - objective-c

So I am currently working on an iPad App (iOS 6) that shows a webpage that is located on my company's intranet. The access from the Internet is achieved via a reverse proxy which works great.
The problem is that this webpage is referencing a JavaScript file that is apprently loaded after the webpage is rendered on the client which results in some jQuery scripts not being run on load time. What works is this:
open the website through the reverse proxy
wait for the webViewDidFinishLoad delegation method to be called
then do [webView reload];
After this, the javascript code is successfully executed. However the solution is not pretty and results in extended wait times.
Are there any solutions to ensure that all referenced files are loaded before rendering takes place?
Thank you!
Christoph

You'll have to fix the webpage so that it doesn't try to run the javascript until the file has actually loaded.

Look up the UIWebView property that was added in iOS 6 called suppressesIncrementalRendering -- I think that will do exactly what you're looking for.

The problem was the way I had the UIWebViewer interact with the Reverse Proxy.
Getting the HTML code through the proxy without involving my webviewer object resulted in a delayed javascript loading.
However, after doing one test connection through the reverse proxy authorization class, I could use this method to load all subsequent webpages w/o any problems:
[webView loadRequest:request];
Thanks everyone for your ideas and feedback!
Christoph

Related

Splash not executing Javascript when proxy is used

i am using scrapy_splash to crawl pages that requires js to retrieve proper content.
Everything is fine when I use SplashRequest without proxy settings, but when I put in proxy settings, the javascript would not render, giving me prejavascript html content which do not have the data I need.
Does anyone know how to solve this? I am sure the proxy ip are not blacklisted.
I can't comment,
But the short answer is because the proxy that you use don't allow to run javascript codes.
Please try another proxy that allow you run javascript code
it turns out to be a slow proxy. I had to set wait to 10 to get result. Thanks for the help guys.

What is the best way to test WebdriverIO "browser" object?

I started using WebdriverIO and noticed that the browser object it provides has a ton of methods, so I would like to play with it without having to run things from CLI.
Is it even possible to do something like open the page I want to run tests against on my browser and somehow use that object from the browsers console to see the results of the methods?
Thank you.
If you'd like to run JavaScript from within the browser, take a look at the 'execute' command.
There's also a full page of docs on the browser object for reference.

Safari Web Content quit unexpectedly

This is a bit of a strange bug that I haven't seen before. When loading the login page for a webapp I'm working on in Safari (Mac OS 10.8.2), the entire browser crashes and quits, with the message "safari web content quit unexpectedly". I don't think I've ever seen a site actually crash a browser before, outside of an infinite loop in javascript or something (and really, it doesn't seem like it should be possible). Is there any Apache header or something that is known to crash Safari? Any help pointing me in the right direction would be appreciated.
What I've Done:
Removed all meta tags and it still crashed.
It is getting the SSL certificate before it crashes, because I got the security warning (certificate doesn't match the url, since I'm testing locally)
It's crashing almost immediately, so I doubt that there's any javascript that's causing it
Use the process of elimination. Remove some code, test app. If it doesn't work, continue removing code until you find the cause.
In case anyone ever happens to stumble across this question, the problem ended up being using CSS3 transitions in conjunction with calc() values. Apparently having them together causes Safari to crash (before the transition is even triggered, I might add). I solved it by doing some simple browser detection to add a class to the body when the browser was anything but Safari, and only do the transitions related to calc() values on elements inside that class.

Using UIWebView as a script engine

I am working on a survey engine for the iPhone. We use a declarative xml format that can be downloaded post store install. It's working pretty well but not being able to script is becoming problematic. I have this idea to use a webView to execute javascript code to provide this functionality.
My question is will this run afoul of Apple's rule of not downloading executable script code? They do seem to allow for downloading of JS code that will run in a web view. Would they consider this approach an abuse of this rule?
Thanks
I don't think so. A lot of native applications are actually built this way. They simply open a webview and load a web page, with all the logic done in javascript.

ASP.net Ajax Partial Rendering using UpdatePanel not working in WebKit browsers

I am part of the developer team for a quite a large online system using ASP.NET(4).
Asp.net Ajax completely breaks down for Webkit browsers and we are getting full page postbacks when we should be getting partial only for the UpdatePanels.
I am starting to believe it has something to do with my Application Configuration, mainly for the following reasons.
If I move the ajax enabled controls to a new project they will work as expected for all browsers, including Webkit.
I created a static .aspx file with nothing but an UpdatePanel,ScriptManager and a button making a literal visible on click.
I get no Javascript errors from any browser, and i see an http request for the asp.net-ajax (ScriptResource.axd) in both Firebug and Chrome Developer tools
I tried ye'old safari fix from this highly referenced thread
Edit: After a bit more testing and http sniffing i noticed a major difference between the test application and the actual application. The test application generates 2 additional .axd files which are not generated from the actual application. These WebResource.axd, seem to contain data related to the async postback. However this is only the case for Webkit browsers. The WebResource.axd files are generated for Firefox as i can see them in firebug
What i am asking from the community, is any ideas or suggestions as to what could be the cause of this problem and if i am correct to assume that the problem is probably on the server side
Thanks for any help
The problem was due to a deprecated config file that's used to limit the content that bots/spiders/crawlers receive, which was loading by mistake thanks to our lovely inhouse CMS
In short if u get behavior similar to my case, check your or configs
I was having a similar issue however my problem was with all browsers and not just webkit. I ended up going through and tearing up the web.config file and found out that a line: <xhtmlConformance mode="Legacy"> was preventing webresource.axd from working properly. The fix was to simply remove that line from my web.config file.
For a little more information on xhtmlConformance, visit http://technet.microsoft.com/en-us/librarY/ms228268(v=vs.85).aspx.
If you scroll all the way to the bottom you'll notice it explicitly states that it causes issues with webresource.axd and scriptresource.axd.