HTML book-like pagination

Building on Dan’s answer here is my solution for this problem, with which I was struggling myself until just now. (this JS works on iOS Webkit, no guarantees for android, but please let me know the results) var desiredHeight; var desiredWidth; var bodyID = document.getElementsByTagName(‘body’)[0]; totalHeight = bodyID.offsetHeight; pageCount = Math.floor(totalHeight/desiredHeight) + 1; bodyID.style.padding = … Read more

Call JavaScript function from native code in WKWebView

(I filed a Radar for this shortly after asking the question here.) A new method was just added a few days ago (thanks jcesarmobile for pointing it out): Add -[WKWebView evaluateJavaScript:completionHandler:] http://trac.webkit.org/changeset/169765 The method is available in iOS 8 beta 3 and up. Here’s the new method signature: /* @abstract Evaluates the given JavaScript string. … Read more

In Chrome, how many redirects are “too many”?

Google Chrome 17.0.963.56 allows a maximum of 20 redirects, as tested with this PHP script: <?php $redirect = (isset($_GET[‘redirect’])) ? $_GET[‘redirect’] : 0; header(“Location: redirects.php?redirect=” . ($redirect + 1)); ?> Chrome aborts with error 310 when trying to open redirects.php?redirect=21, which means that the first 20 redirects were successful.

How do I remove all default Webkit search field styling?

Try these stylings: input[type=”search”]::-webkit-search-decoration, input[type=”search”]::-webkit-search-cancel-button, input[type=”search”]::-webkit-search-results-button, input[type=”search”]::-webkit-search-results-decoration { -webkit-appearance:none; } Source: http://css-tricks.com/webkit-html5-search-inputs/#comment-82432

Disable magnification gesture in WKWebView

You can prevent your users from zooming by setting the delegate of your WKWebKit’s UIScrollView and implementing viewForZooming(in:) as in the following: class MyClass { let webView = WKWebView() init() { super.init() webView.scrollView.delegate = self } deinit() { // Without this, it’ll crash when your MyClass instance is deinit’d webView.scrollView.delegate = nil } } extension … Read more

Div scrolling freezes sometimes if I use -webkit-overflow-scrolling

For me, the freezing was repeatable and happened when trying to scroll up or down when already at the top or bottom, respectively. The fix was to add some listeners for touchstart and touchmove and detect these cases and event.preventDefault() on ’em. Something like the following, where .scroller is the div that will actually scroll … Read more

How do you handle oncut, oncopy, and onpaste in jQuery?

You can add and remove events of any kind by using the .on() and off() methods Try this, for instance jQuery(document).on(‘paste’, function(e){ alert(‘pasting!’) }); jQuery is actually quite indifferent to whether the event type you assign is supported by the browser, so you can assign arbitrary event types to elements (and general objects) such as: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)