I am using html2canvas js but not be Screenshot Capture by page url
Loading
I am using html2canvas js but not be Screenshot Capture by page url
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mithilesh TataRank #862 · 2.6K reputationPosted Feb 29, 2024, 2:35 AM EST
To take a screenshot of a webpage URL using jQuery and PHP, you can use a combination of client-side and server-side code. Here's a basic approach:
Client-Side (jQuery): Use jQuery to send an AJAX request to the server with the URL of the webpage to capture the screenshot.
Server-Side (PHP): Use PHP to capture the screenshot of the webpage URL using a headless browser or a third-party service like Puppeteer or PhantomJS.
Below is an example implementation:
Client-Side (jQuery):
Take Screenshot $(document).ready(function(){ $('#captureScreenshot').click(function(){ var url = $('#urlInput').val(); $.ajax({ type: 'POST', url: 'capture.php', data: {url: url}, success: function(response){ // Handle the response (e.g., display the screenshot) console.log(response); }, error: function(xhr, status, error){ console.error(xhr.responseText); } }); }); }); Take Screenshot Capture ScreenshotServer-Side (PHP -
capture.php):In this example, when the user enters a URL and clicks the "Capture Screenshot" button, jQuery sends an AJAX POST request to
capture.phpalong with the URL. The PHP script then captures the screenshot of the provided URL (you need to implement this part using a headless browser or a third-party service), and returns the screenshot data back to the client.Please note that capturing a screenshot using headless browsers or third-party services might require additional setup and configuration. Ensure that you have the necessary permissions and resources to execute such tasks on your server. Additionally, consider security implications and handle user inputs appropriately to prevent security vulnerabilities like XSS (Cross-Site Scripting) attacks.