PDA

View Full Version : how to save iFrame content (page) ?


Alias
06-26-2002, 03:29 AM
Hello,

does anybody knows how to save page of iFrame ?
(with click on image wich is placed above of iFrame)

I try with many combinations ... but nothing :mad:
this problem needs expert I think, not a newbie like me ... :(


<iframe name="external" id="external" frameborder="0" style="width:700px;height:500px;" src="home.htm"></iframe>

(sorry for my bad english)

Regards :confused:

boxer_1
06-26-2002, 06:31 AM
This script will allow you to give the user the option to save the page within the iframe (home.html). However, in its current state, you'll have to place the script within the html page that loads into the iframe. I'm sure there's a way to access the iframe form the document containing it, allowing you to save the content of the iframe by clicking on an image outside of it, but I'm too tired right now to figure it out...lol (1:30 AM here) :eek:

Anyway, here's the script. It will save the content of the iframe if you place it into the html doc that loads into the iframe. It will, of course, bring up the save as dialog box to allow the user to confirm the fact that they want to save the doucument in the iframe:

<html>
<head>
<title>Save as example</title>
<script language="JavaScript" type="text/JavaScript">
var now = false;
function saveIt(){
if (now){document.execCommand("SaveAs");}
}
</script>
</head>
<body onLoad="now=true">
<a href="javascript:;" onClick="saveIt();">
Save This Page
</a>
</body>
</html>

Good luck ;).

Alias
06-26-2002, 12:23 PM
Thanx Boxer ... :)

But my problem is how to save the iframe page form the document containing it (with click on image wich is placed above of iFrame) ?

Possible ?

boxer_1
06-26-2002, 03:57 PM
Originally posted by Alias
Thanx Boxer ... :)

But my problem is how to save the iframe page form the document containing it (with click on image wich is placed above of iFrame) ?

Possible ?

Ok, here we go ;). I've modified the script so it will save the htm page that you're calling into your iframe by clicking an image outside the iframe (in the page containing the iframe).

For the first part, you have to place the following inside the page to be loaded into the iframe. This would be 'home.htm' in your example the bolded part is what you need to add to home.htm):

<html>
<head>
<title>the iframe to be saved</title>
<script language="JavaScript" type="text/JavaScript">
var now = false;
function saveIt(){
if (now){document.execCommand("SaveAs");}
}
</script>
</head>
<body onLoad="now=true">
<!-- This page is home.htm in your example -->
This is the html page that will load into the iframe.
Also the html document that the user will be given the
option to save by clicking on an image above the iframe.
</body>
</html>

Next, you need to place the bolded part below into the page where you have the iframe (the page were you have the picture you want to click to save the page within the iframe):

<html>
<head>
<title>Save as example</title>
</head>
<body>
<a href="javascript:;" onClick="document.frames('external').saveIt();">
<img src="yourImage.gif" name="yourGraphic" border="0" width="50" height="50">
</a>
<br />
<iframe src="home.htm" width="700" height=500" id="external" name="external"></iframe>
</body>
</html>

Does this accomplish what you are trying to do? :thumbsup:

PS: Of course you'll have to change the image I used in the example to the one you wish to have the user click on to save the contents of the iframe ;).

Alias
06-26-2002, 09:24 PM
Thanks once again Boxer to time dedicated to my problem


but .. i tried your script and unfortunately it continues
to save my top page - not the iFrame page. :(

When I start to puting "SaveAs" button on my
page with IFrame, I was thinking that it will be simple thing ...
... and now I see that it is so hard ... ????? :confused:

What to do ?

boxer_1
06-27-2002, 12:00 AM
Originally posted by Alias
Thanks once again Boxer to time dedicated to my problem


but .. i tried your script and unfortunately it continues
to save my top page - not the iFrame page. :(

When I start to puting "SaveAs" button on my
page with IFrame, I was thinking that it will be simple thing ...
... and now I see that it is so hard ... ????? :confused:

What to do ?

Ok, the fact that you are getting prompted to save the 'top page' (the page the ifram is contained in) tells me that you must still have the code in the containing page, as opposed to the page that loads into the iframe ;). The only part that should go into the page containing the iframe is:

<a href="java script:;" onClick="saveIt();">
Save This Page
</a>

I uploaded a simple example to some testing space I have to see if it works for you there (not 100% cross-browser, just wanted to say that in case someone else visits with NS 4x). Here's the link:

http://www.kynd.com/~buyswap/Alias.html

Check it out and let me know if it promts you to save home.htm (as it should) or Alias.html. If it works, save both pages for reference ;).

PS: If anyone else visits, could you post what page you were prompted to save just for reference ;)?

Alias
06-27-2002, 01:05 AM
Heeeeeeeyyyyyy Boxer !!!!
YOU ARE GREAT ... Thank you so much for you time dedicated to my problem !!!

But ... result (which is not so important - because i'm so impresed with your energy for my problem) is not so good:
with IE 5.0 it promts to save Alias.htm
NS 4.0 of course, don't shows the iFrame
and NS 6.0 not respond when I click to save home.htm

I'm trying with other combinations ... but nothing ... :(

boxer_1
06-27-2002, 01:24 AM
Originally posted by Alias
Heeeeeeeyyyyyy Boxer !!!!
YOU ARE GREAT ... Thank you so much for you time dedicated to my problem !!!

But ... result (which is not so important - because i'm so impresed with your energy for my problem) is not so good:
with IE 5.0 it promts to save Alias.htm
NS 4.0 of course, don't shows the iFrame
and NS 6.0 not respond when I click to save home.htm

I'm trying with other combinations ... but nothing ... :(

You're welcome on the time spent. Unfortunately, the solution I provided is (in its current state anyway), only workable in IE 6 (don't know about IE 5.5). Sorry I couldn't provide a more cross-browser solution. Maybe someone else here will be able to tweak what I put together or provide a completely different solution. I'm stumped at this point :confused: . I didn't intend to drag you down this long path just to wind up at square 1 again.

I'll give it some further thought. In the mean time, I'll move this over to the "Post / Request a script" forum for continuance as that forum is more relevant to this task / request as it has become nearly an exclusive JavaScript issue at this point ;).

Alias
06-27-2002, 01:37 AM
OK ... :)

If I understand good, it works in IE 6 ?

Alias
07-01-2002, 01:01 AM
???

boxer_1
07-01-2002, 03:28 AM
Hello again Alias, I see you're still searching for an answer to your question. I have'nt forgotten about it, I just can't think of a cross-browser solution.

Out of curiousity, what do you offer in 'home.htm' (the page that loads into your iframe) that you wish to give the user the option to download? The answer might help to figure out some possible workarounds you could use ;).

Alias
07-03-2002, 08:55 PM
Hello Boxer :)

well, pages in iFrame are nothing special, pictures and text ...
I'm making fullscreen site and I want to have "Save As" option for visitors ...

well if i find solution i will post it

;)

Best Regards

sonaltandon
11-24-2008, 12:56 PM
Hi Boxer,

I am still facing the problem
here is my code snippet!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<iframe id='ipdf' name='ipdf' src='c:\fdffiles\check.fdf' width=880 height=900></iframe>
<input type="submit" id = "button" name="Submit" value="Save Comments" onClick="document.frames('ipdf').extract();">
<script>
function extract(){
var fname="xxx.pdf";
// document.getElementById("ipdf").execCommand('SaveAs', null,fname);
// document.frames['ipdf'].saveIt();
document.execCommand("SaveAs",null,"xxxxx.pdf");

alert("extracted");

}
</script>
</BODY>
</HTML>

ther is a javascript error
please let me know what to do?
plz!!!

saran3
11-25-2008, 07:49 AM
I am not sure what you want
but if you want this page to work, you need to create a page called "home.html", and put everything in that home.html so that whatever put in home.html will appear

<iframe name="external" id="external" frameborder="0" style="width:700px;height:500px;" src="home.htm"></iframe>

inserting anything between the tag has no effect to the page!

I hope this is what you want



handbagsdealer (http://www.handbagsdealer.com)