English 中文(简体)
HTML5 s scrap + Javascript 和 iOS 无效的 Javascript 代码
原标题:HTML5 s canvas + Javascript code not working on iOS

我完成了一个简陋的 javascript + html5 s scrap 引擎。 非常简陋。 它在浏览器上起作用, 但是在iOS上却行不通 。

我是否使用一个尚未在Safari Mobile上执行的功能?

http://bluuecodestudio.com/kipos/gametest.html

最佳回答

在键盘 JS. init () 中, 您正在对事件回调使用绑定() 方法 。

document.addEventListener("keydown", this.keyIsDown.bind(this));
document.addEventListener("keyup", this.keyIsUp.bind(this));

Safari (包括移动的Safari) 不支持绑定() 方法。 您需要提供一个多填充 :

/**
*    Bind.js
*    Copyright 2010, WebReflection
*    License: http://www.opensource.org/licenses/mit-license.php
*/
if (Function.prototype.bind === null || Function.prototype.bind === undefined) {
    Function.prototype.bind = (function (slice) {
        // (C) WebReflection - Mit Style License
        function bind(context) {
            var self = this; // "trapped" function reference
            // only if there is more than an argument
            // we are interested into more complex operations
            // this will speed up common bind creation
            // avoiding useless slices over arguments
            if (1 < arguments.length) {
                // extra arguments to send by default
                var $arguments = slice.call(arguments, 1);
                return function () {
                    return self.apply(
                        context,
                    // thanks @kangax for this suggestion
                        arguments.length ?
                    // concat arguments with those received
                            $arguments.concat(slice.call(arguments)) :
                    // send just arguments, no concat, no slice
                            $arguments
                    );
                };
            }
            // optimized callback
            return function () {
                // speed up when function is called without arguments
                return arguments.length ? self.apply(context, arguments) : self.call(context);
            };
        }

        // the named function
        return bind;

    } (Array.prototype.slice));
}
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签