Web Analytics Made Easy -
StatCounter how to save iFrame content (page) ? - CodingForum

Announcement

Collapse
No announcement yet.

how to save iFrame content (page) ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to save iFrame content (page) ?

    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
    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

  • #2
    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)

    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 .
    Last edited by boxer_1; Jun 27, 2002, 07:43 PM.
    boxer_1
    CodingForum Moderator
    "How did a fool and his money get together in the first place?"

    Comment


    • #3
      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 ?

      Comment


      • #4
        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?

        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 .
        Last edited by boxer_1; Jun 27, 2002, 07:44 PM.
        boxer_1
        CodingForum Moderator
        "How did a fool and his money get together in the first place?"

        Comment


        • #5
          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 ... ?????

          What to do ?

          Comment


          • #6
            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 ... ?????

            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 ?
            boxer_1
            CodingForum Moderator
            "How did a fool and his money get together in the first place?"

            Comment


            • #7
              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 ...

              Comment


              • #8
                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 . 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 .
                boxer_1
                CodingForum Moderator
                "How did a fool and his money get together in the first place?"

                Comment


                • #9
                  OK ...

                  If I understand good, it works in IE 6 ?

                  Comment


                  • #10
                    ???

                    Comment


                    • #11
                      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 .
                      boxer_1
                      CodingForum Moderator
                      "How did a fool and his money get together in the first place?"

                      Comment


                      • #12
                        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

                        Comment


                        • #13
                          still in a problem

                          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!!!

                          Comment


                          • #14
                            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

                            Comment

                            Working...
                            X