Results 1 to 6 of 6

Thread: Saving only a portion of webpage into a file

  1. #1
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Saving only a portion of webpage into a file

    hello,
    im working on a web application that generates dynamic data. My question is: i want users to be able to save the generated data, but not the whole web page, just a table in the web page that holds this data. I searched and found out that showing a "save as" dialog box is possible with javascript, with a method like: onclick="javascript: document.execCommand('SaveAs','1',null);. However, i coulnd't find out how to change the document object (or is it possible?) or a trick to print just the table of dynamic data. I tried to cover the table with <div id="myData"></div> and use onclick="javascript: myData.execCommand('SaveAs','1',null); but as you might guess, it didn't work and gave this error message: "object doent support this property or method". Indeed i dont have any idea what div tag can and can't do, so it was just a meaningless try. By the way, i want to add that i can't use iframes just because of program design issues.
    Anyway, do you have any suggestions?

    thanks in advance,
    ibrahim saygılı

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Can't order a save from a webpage. Put the data in a textbox and add a "select all" button like the links on DD's scripts.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes, you can. with document.execCommand('SaveAs','1',null); method of javascript.

    my question is: can i put a portion of web page into an object in javascript? if so, another solution would be sending that object to a popup window and print the content of popup window. but how?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    yes, you can. with document.execCommand('SaveAs','1',null); method of javascript.
    No, you can't. That's not a Javascript method; it's a JScript method, meaning that it will only work on Internet Explorer (SaveAs, that is; execCommand exists on other browsers).
    The second idea is better, and you can use window.print() to print it.
    Code:
    <script type="text/javascript">
      function printElement(id) {
        var v = window.open();
        v.document.open();
        v.document.write(
          "<html>" +
            "\t<head>" +
              "\t\t<title>" +
                "Mysite.com :: Printing Window" +
              "</title>" +
            "\t</head>" +
            "\t<body>" +
              document.getElementById(id).innerHTML.toString() +
            "\t</body>" +
          "</html>"
        );
        v.document.close();
        v.print();
      }
    </script>
    Last edited by Twey; 04-29-2006 at 12:51 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    ok i just saw the code.. looking for it

  6. #6
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you in advance, it seems quite fitting for me.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •