Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using iframe tag to display image. Also there is a Save Image Button on page. I want that when user click the button, then the image inside iframe should save on desktop.
Remember i want only image to be saved on desktop not the whole page.
How to do this...plz help

eg:
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    <script type="text/JavaScript">
        var now = false;
        function saveIt() {
            if (now) { document.execCommand("SaveAs"); }
        }
</script>
</head>
<body  önload="now=true">
    <form id="form1"  runat="server">
            
    <pre lang="xml"><asp:Button ID="Button1" runat="server" OnClientClick="saveIt();" Text="Save" />
    <br />

    <iframe src="Images/findr.png" width="400px" height="400px" id="external" name="external"></iframe>
   
    </form>
</body>
</html>

[edit]Unnecessary code block removed[/edit]

[Update removed from answer]
XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function saveIt() {
imgURL = document.getElementById('external');
if (typeof imgURL == 'object')
imgURL = imgURL.src;
window.win = open(imgURL);
setTimeout('win.resizeTo(0, 0);', 100);
setTimeout('win.moveTo(0, 0);', 200);
setTimeout('win.document.execCommand("SaveAs")', 500);
setTimeout('win.close()', 1000);
}
</script>
</head>
<body>
<form id="form1" runat="server">

    <input type="button" id="Button1" runat="server" onclick="saveIt();" value="Save" />

    <iframe src="Images/orderedList3.png" width="400px" height="400px">
id="external" name="external">
    </iframe>

</form>
</body>
</html>

try on IE.
Posted
v7
Comments
What is the issue?
Raj Negi 2-Mar-14 13:45pm    
i added the sample code...plz review
JoCodes 28-Feb-14 7:36am    
you need to post the Code you tried with the Question so that it would be easy for others to help you as well.
Raj Negi 2-Mar-14 13:44pm    
ok sure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900