簡體   English   中英

觸發Google Plus上加號按鈕的點擊事件

[英]Trigger click event of plus button on google plus

我無法觸發Google Plus中加號按鈕的事件onClick

在此處輸入圖片說明

我嘗試了一種方法:

在此處輸入圖片說明

但這沒有用。

我試過的代碼

    $(".mUbCce.fKz70d.GsLz7c.teCjMb.M9Bg4d").click()

我還注意到,當我將鼠標懸停在加號按鈕上時,鼠標圖標變為“ hand-icon”,但是我沒有找到任何CSS光標。

谷歌有什么魔術嗎?

謝謝

試試這個:定義一個函數fireEvent()像這樣:

    function fireEvent(node, eventName) {
    // Make sure we use the ownerDocument from the provided node to avoid cross-window problems
    var doc;
    if (node.ownerDocument) {
        doc = node.ownerDocument;
    } else if (node.nodeType == 9){
        // the node may be the document itself, nodeType 9 = DOCUMENT_NODE
        doc = node;
    } else {
        throw new Error("Invalid node passed to fireEvent: " + node.id);
    }

    if (node.dispatchEvent) {
        // Gecko-style approach (now the standard) takes more work
        var eventClass = "";

        // Different events have different event classes.
        // If this switch statement can't map an eventName to an eventClass,
        // the event firing is going to fail.
        switch (eventName) {
            case "click": // Dispatching of 'click' appears to not work correctly in Safari. Use 'mousedown' or 'mouseup' instead.
            case "mousedown":
            case "mouseup":
            eventClass = "MouseEvents";
            break;

            case "focus":
            case "change":
            case "blur":
            case "select":
            eventClass = "HTMLEvents";
            break;

            default:
            throw "fireEvent: Couldn't find an event class for event '" + eventName + "'.";
            break;
        }
        var event = doc.createEvent(eventClass);

        var bubbles = eventName == "change" ? false : true;
        event.initEvent(eventName, bubbles, true); // All events created as bubbling and cancelable.

        event.synthetic = true; // allow detection of synthetic events
        // The second parameter says go ahead with the default action
        node.dispatchEvent(event, true);
    } else  if (node.fireEvent) {
        // IE-old school style
        var event = doc.createEventObject();
        event.synthetic = true; // allow detection of synthetic events
        node.fireEvent("on" + eventName, event);
    }

};

並致電

  fireEvent($0,"mousedown")
  fireEvent($0,"mouseup")

$ 0是您要單擊的元素

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM