PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 15, 2022

[FIXED] how can download webapge as .html/.png after i inputed text in text box below is my code

 July 15, 2022     bootstrap-4, html, javascript, web, web-deployment     No comments   

Issue

how can download webapge as .html/.png after i inputed text in text box below is my code

<div class="container">
<form>
    <div class="form-group">
        <label for="link">Paste Website Link Below</label>
        <input type="link" class="form-control" id="download" placeholder="Enter website link" >
      <br>
    <butt class="btn btn-primary">Download </button>

</form></div>


i know this thing works for downloading webpage or any file but want when we type link their and then download help


Solution

This function will create an <a> element and assign the download link to it, then click it.

function download() {
  var link = document.createElement("a");
  link.setAttribute("href", document.getElementById("download").value);
  link.setAttribute("download", "");
  link.click();
}

Your button should look like...

<button class="btn btn-primary" onclick="download()">Download</button>


Answered By - Daemon Beast
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing