Sofiaml Boo

Sofiaml Boo

1588630020

How to Create a Screenshot with JavaScript and HTML

Generate a screenshot using HTML and JavaScript, yeah that is what I meant.

Procedure

Step 1

You need an HTML page with some JavaScript code and CSS. That’s all we need.

Create an HTML file just like this:

<html lang="en">    
<head>    
    <title>Take Web Page Screenshot with HTML5 and JavaScript </title>    
</head>    
<body>    
    <a class="btn btn-success" href="javascript:void(0);" onclick="generate();">Generate    
        Screenshot »</a>        
</body>    
</html>  

Step 2

If you want, you can create some styles and apply them.

Now it’s time to create the JavaScript function generate() that I specified in an tag.

<script type="text/javascript">    
        (function (exports) {    
            function urlsToAbsolute(nodeList) {    
                if (!nodeList.length) {    
                    return [];    
                }    
                var attrName = 'href';    
                if (nodeList[0].__proto__ === HTMLImageElement.prototype || nodeList[0].__proto__ ===         
                 HTMLScriptElement.prototype) {    
                    attrName = 'src';    
                }    
                nodeList = [].map.call(nodeList, function (el, i) {    
                    var attr = el.getAttribute(attrName);    
                    if (!attr) {    
                        return;    
                    }    
                    var absURL = /^(https?|data):/i.test(attr);    
                    if (absURL) {    
                        return el;    
                    } else {    
                        return el;    
                    }    
                });    
                return nodeList;    
            }    
    
            function screenshotPage() {    
                urlsToAbsolute(document.images);    
                urlsToAbsolute(document.querySelectorAll("link[rel='stylesheet']"));    
                var screenshot = document.documentElement.cloneNode(true);    
                var b = document.createElement('base');    
                b.href = document.location.protocol + '//' + location.host;    
                var head = screenshot.querySelector('head');    
                head.insertBefore(b, head.firstChild);    
                screenshot.style.pointerEvents = 'none';    
                screenshot.style.overflow = 'hidden';    
                screenshot.style.webkitUserSelect = 'none';    
                screenshot.style.mozUserSelect = 'none';    
                screenshot.style.msUserSelect = 'none';    
                screenshot.style.oUserSelect = 'none';    
                screenshot.style.userSelect = 'none';    
                screenshot.dataset.scrollX = window.scrollX;    
                screenshot.dataset.scrollY = window.scrollY;    
                var script = document.createElement('script');    
                script.textContent = '(' + addOnPageLoad_.toString() + ')();';    
                screenshot.querySelector('body').appendChild(script);    
                var blob = new Blob([screenshot.outerHTML], {    
                    type: 'text/html'    
                });    
                return blob;    
            }    
    
            function addOnPageLoad_() {    
                window.addEventListener('DOMContentLoaded', function (e) {    
                    var scrollX = document.documentElement.dataset.scrollX || 0;    
                    var scrollY = document.documentElement.dataset.scrollY || 0;    
                    window.scrollTo(scrollX, scrollY);    
                });    
            }    
    
            function generate() {    
                window.URL = window.URL || window.webkitURL;    
                window.open(window.URL.createObjectURL(screenshotPage()));    
            }    
            exports.screenshotPage = screenshotPage;    
            exports.generate = generate;    
        })(window);    
    </script>   

Complete Code

Screenshot.html

<html lang="en">    
<head>    
    <title>Take Web Page Screenshot with HTML5 and JavaScript </title>    
</head>    
<body>    
    <a class="btn btn-success" href="javascript:void(0);" onclick="generate();">Generate    
        Screenshot »</a>    
    <script type="text/javascript">    
        (function (exports) {    
            function urlsToAbsolute(nodeList) {    
                if (!nodeList.length) {    
                    return [];    
                }    
                var attrName = 'href';    
                if (nodeList[0].__proto__ === HTMLImageElement.prototype || nodeList[0].__p                   roto__ === HTMLScriptElement.prototype) {    
                    attrName = 'src';    
                }    
                nodeList = [].map.call(nodeList, function (el, i) {    
                    var attr = el.getAttribute(attrName);    
                    if (!attr) {    
                        return;    
                    }    
                    var absURL = /^(https?|data):/i.test(attr);    
                    if (absURL) {    
                        return el;    
                    } else {    
                        return el;    
                    }    
                });    
                return nodeList;    
            }    
    
            function screenshotPage() {    
                urlsToAbsolute(document.images);    
                urlsToAbsolute(document.querySelectorAll("link[rel='stylesheet']"));    
                var screenshot = document.documentElement.cloneNode(true);    
                var b = document.createElement('base');    
                b.href = document.location.protocol + '//' + location.host;    
                var head = screenshot.querySelector('head');    
                head.insertBefore(b, head.firstChild);    
                screenshot.style.pointerEvents = 'none';    
                screenshot.style.overflow = 'hidden';    
                screenshot.style.webkitUserSelect = 'none';    
                screenshot.style.mozUserSelect = 'none';    
                screenshot.style.msUserSelect = 'none';    
                screenshot.style.oUserSelect = 'none';    
                screenshot.style.userSelect = 'none';    
                screenshot.dataset.scrollX = window.scrollX;    
                screenshot.dataset.scrollY = window.scrollY;    
                var script = document.createElement('script');    
                script.textContent = '(' + addOnPageLoad_.toString() + ')();';    
                screenshot.querySelector('body').appendChild(script);    
                var blob = new Blob([screenshot.outerHTML], {    
                    type: 'text/html'    
                });    
                return blob;    
            }    
    
            function addOnPageLoad_() {    
                window.addEventListener('DOMContentLoaded', function (e) {    
                    var scrollX = document.documentElement.dataset.scrollX || 0;    
                    var scrollY = document.documentElement.dataset.scrollY || 0;    
                    window.scrollTo(scrollX, scrollY);    
                });    
            }    
    
            function generate() {    
                windowwindow.URL = window.URL || window.webkitURL;    
                window.open(window.URL.createObjectURL(screenshotPage()));    
            }    
            exports.screenshotPage = screenshotPage;    
            exports.generate = generate;    
        })(window);    
    </script>    
</body>    
</html>   

Happy coding!

#javascript #html #css

What is GEEK

Buddha Community

How to Create a Screenshot with JavaScript and HTML

Kannan BS

1588696195

hai

Kannan BS

1588696195

hai

Jake King

1614747045

Looks like you copied the orginal post without knowing what the code was doing.

The correct terminology is SNAPSHOT … not screenshot.
A screenshot is an image.
A SNAPSHOT is a copy of the original source.
But do not worry, neither you nor any others that can copied this source, without attibuting the orginal author, knows the difference.

Lyda  White

Lyda White

1628189100

How to Image Uploader with Preview || Html CSS JavaScript

Image Uploader with Preview || Html CSS JavaScript || #html #css #javascript #coding

#html #css #javascript 

Ava Watson

Ava Watson

1595318322

Know Everything About HTML With HTML Experts

HTML stands for a hypertext markup language. For the designs to be displayed in web browser HTML is the markup language. Technologies like Cascading style sheets (CSS) and scripting languages such as JavaScript assist HTML. With the help of HTML websites and the web, designs are created. Html has a wide range of academic applications. HTML has a series of elements. HTML helps to display web content. Its elements tell the web how to display the contents.

The document component of HTML is known as an HTML element. HTML element helps in displaying the web pages. An HTML document is a mixture of text nodes and HTML elements.

Basics of HTML are-

The simple fundamental components oh HTML is

  1. Head- the setup information for the program and web pages is carried in the head
  2. Body- the actual substance that is to be shown on the web page is carried in the body
  3. HTML- information starts and ends with and labels.
  4. Comments- come up in between

Html versions timeline

  1. HTML was created in 1990. Html is a program that is updated regularly. the timeline for the HTML versions is
  2. HTML 2- November, 1995
  3. HTML 3- January, 1997
  4. HTML 4- December, 1997; April, 1998; December, 1999; May, 2000
  5. HTML 5- October, 2014; November, 2016; December, 2017

HTML draft version timelines are

  1. October 1991
  2. June 1992
  3. November 1992
  4. June 1993
  5. November 1993
  6. November 1994
  7. April 1995
  8. January 2008
  9. HTML 5-
    2011, last call
    2012 candidate recommendation
    2014 proposed recommendation and recommendation

HTML helps in creating web pages. In web pages, there are texts, pictures, colouring schemes, tables, and a variety of other things. HTML allows all these on a web page.
There are a lot of attributes in HTML. It may get difficult to memorize these attributes. HTML is a tricky concept. Sometimes it gets difficult to find a single mistake that doesn’t let the web page function properly.

Many minor things are to be kept in mind in HTML. To complete an HTML assignment, it is always advisable to seek help from online experts. These experts are well trained and acknowledged with the subject. They provide quality content within the prescribed deadline. With several positive reviews, the online expert help for HTML assignment is highly recommended.

#html assignment help #html assignment writing help #online html assignment writing help #html assignment help service online #what is html #about html

CSS Boss

CSS Boss

1606912089

How to create a calculator using javascript - Pure JS tutorials |Web Tutorials

In this video I will tell you How to create a calculator using javascript very easily.

#how to build a simple calculator in javascript #how to create simple calculator using javascript #javascript calculator tutorial #javascript birthday calculator #calculator using javascript and html

code savvy

code savvy

1630506330

Product landing page using HTML CSS & JavaScript | web design

Knowledge

This video is about the product landing page using HTML CSS And JavaScript, in which we created a simple product landing page using HTML CSS and in order to perform  those powerful animations we use the GSAP a JavaScript animation library for work done.

In this video we broadly cover the concepts of CSS Flex box and CSS Grid system and Some CSS Properties such as nth child selector, ::before & ::after much more.

Don't forget to join the channel for more videos like this. Code Savvy

📁 Assets 
Icons : https://fontawesome.com/
Fonts : https://fonts.google.com/
GitHub : https://github.com/ananikets18
GSAP : https://greensock.com/gsap/

Outline ⏱

0:00 - Intro
0:10 - Result
0:38 - Project Setup
01:35 – Reset HTML
02:21 – Left Container HTML
03:41 – Wrapper
14:58 – Bottom Shoe Nav
26:23 – Right Container HTML
33:10 – Product Size
35:49 – Reviews
41:11 – GSAP Animations

Click to Watch Full tutorial on YOUTUBE

#html  #css  #javascript  #web-development #html5 

#html #css #tailwindcss #javascript 

code savvy

code savvy

1629473371

Web Design Speed Code | HTML, CSS, JavaScript (GSAP) | Portfolio Design

Portfolio Website Design with HTML, CSS & Javascript

 

Hello Everyone, In this video we'll create a Portfolio Page design using HTML, CSS & JavaScript (GSAP) 📁

🧠 Knowledge : 

Html, CSS (Flexbox), JavaScript DOM, Javascript Animations.

Anyway, you can learn everything mentioned. Follow the tutorial.

⏱ Outline

 

#css #javascript  #JavaScript  #HTML #html 

Click to Watch Full Tutorial