Take Screenshot of Browser via JavaScript (or something else)

前端 未结 15 1993
天命终不由人
天命终不由人 2020-12-15 04:43

For support reasons I want to be able for a user to take a screenshot of the current browser window as easy as possible and send it over to the server.

Any (crazy)

15条回答
  •  余生分开走
    2020-12-15 05:14

    You can also do this with the Fireshot plugin. I use the following code (that I extracted from the API code so I don't need to include the API JS) to make a direct call to the Fireshot object:

        var element = document.createElement("FireShotDataElement");
    element.setAttribute("Entire", true);
    element.setAttribute("Action", 1);
    element.setAttribute("Key", "");
    element.setAttribute("BASE64Content", "");
    element.setAttribute("Data", "C:/Users/jagilber/Downloads/whatev.jpg");
    
    if (typeof(CapturedFrameId) != "undefined")
            element.setAttribute("CapturedFrameId", CapturedFrameId);
    
    
    document.documentElement.appendChild(element);
    
    var evt = document.createEvent("Events");
    evt.initEvent("capturePageEvt", true, false);
    
    element.dispatchEvent(evt);
    

    Note: I don't know if this functionality is only available for the paid version or not.

提交回复
热议问题