点击功能不适用于Cordova?

时间:2017-03-19 07:39:13

标签: javascript cordova visual-studio-cordova

我刚刚开始使用Cordova,并且已经弄清楚为什么这个简单的点击事件无法正常工作?下面是我的index.html文件。我读到somwhere,背景必须是无,并且点击不能在手机上工作,而是使用水龙头代替。 Tap没有任何区别。

private static void TestShellFolder()
{
    object recycleBinTemp;
    ShellFolderUtilities.BindToCsidl(ShellFolderUtilities.CSIDL_BITBUCKET, typeof(IShellFolder).GUID, out recycleBinTemp);
    var recycleBin = (IShellFolder)recycleBinTemp;

    var pids = new List<PITEMID_CHILD>();

    try
    {
        foreach (PITEMID_CHILD pidl in recycleBin.Enumerate())
        {
            // Remember to free the pidl!

            string str;

            using (var ret = new STRRET { uType = STRRET_TYPE.CSTR })
            {

                recycleBin.GetDisplayNameOf(pidl, 0, ret);
                str = ret.ToString(pidl);
            }


            // Some condition to include/exclude...
            if (pids.Count < 10)
            {
                Console.WriteLine(str);
                pids.Add(pidl);
            }
            else
            {
                Marshal.FreeCoTaskMem(pidl.Ptr);
            }
        }

        var pids2 = pids.ToArray();

        object cmTemp;
        recycleBin.GetUIObjectOf(IntPtr.Zero, pids2.Length, pids2, typeof(IContextMenu).GUID, IntPtr.Zero, out cmTemp);
        var cm = (IContextMenu)cmTemp;


        // To see verbs
        //var verbsAnsi = ContextMenuUtilities.GetVerbs(cm, true);
        //var verbsUnicode = ContextMenuUtilities.GetVerbs(cm, false);

        var cmd = new CMINVOKECOMMANDINFOEX
        {
            cbSize = Marshal.SizeOf(typeof(CMINVOKECOMMANDINFOEX)),
            fMask = 0x00000400 /* CMIC_MASK_FLAG_NO_UI */,
            lpVerb = "delete",
        };

        cm.InvokeCommand(ref cmd);
    }
    finally
    {
        foreach (var pid in pids)
        {
            Marshal.FreeCoTaskMem(pid.Ptr);
        }
    }
}

2 个答案:

答案 0 :(得分:0)

此问题与cordova无关,在关闭body标签之前放置脚本,因此可以准备好DOM,用ready事件包围脚本

示例

  $(document).ready(function(){
     $(document).on("click", ".gg2", function () {
        console.log('hello');
        $('.gg2').css('background-color', 'blue');
    });
  });

答案 1 :(得分:0)

看起来内联JS被禁用了。请仔细阅读您在第5-6行上粘贴的评论。注释掉Content-Security-Policy行以验证原因。