Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatic printing

    Hi,

    Every two weeks I have to print out about 100 different websites. These sites change data week to week, but not their address. At present, I am just going down the list and printing them manually; is there a java script I can use to run down this list for me? It seems there must, because it's is a fairly basic operation; click, print, next. Right now I have it set up as a frameset, links on the left panel and the target on the right panel, and it seems to work ok, but I'd much rather hit a button and have it print out every link for me.

    I appreciate any help!

    -Ryan

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nope. If there was imagine the havoc malicious haxxors could cause to unsuspecting websites.

    *this has been asked before. you could always find the thread and see the various opinions for yourself, before you get flamed.
    *keep it simple (TM)

  • #3
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I doubt he would get flamed, he asked a legitimate question, and the answer is no, not with Javascript.

    Easiest way would to build a simple program with VB or something, have it loop through each address, display the site (you could use the webbrowser control in VB6 for simplicity), then print it. The move onto the next site.

    Actually, that CAN be done with JS can't it? Just make it loop every 20 seconds or so, load the location into the iframe/frame, print the frame then move onto the next one?

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, right now I am just cycling through; but there's no real gain if I just cycle every 20 seconds and hit print. I'm trying to not click anything at all once I set the script in motion. I don't know VB script, so maybe I'm just stuck printing things out myself. Right now I spend a few hours doing this; it would be really helpful if I could just hit a button, go do something else, and come back to my report printed out without intervention.

  • #5
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's what I meant, but I'm not too knowledgable on Javascript.

    I think you should be able to store each url in an array though, then every so many seconds set the frame location to that of the first url, and print, then move onto the next url in the array.

    I'm sure someone more advanced with JS could code it for you.

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87
    I doubt he would get flamed, he asked a legitimate question
    as did the OP in the other post from way back (long before you were here, anyway), and he defo got flamed.
    *keep it simple (TM)

  • #7
    Regular Coder
    Join Date
    Sep 2005
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you try to use any print function through js, the browser will pop-up a print dialogue box where you have to select the number of copies, etc. (sort of like doing "Print..." as opposed to "Print" in Word). Going back to Jbot's point, imagine how damaging it would be if advertising spammers could tell client computers to automatically printout a web site!

    The only way to do something like this is to:
    a) Run an outside programs (ie a program on your computer) that interacts with the browser to perform the "Print" operation for you. Basically the idea that mark87 proposed.
    b) Run a server-side script where a web-site is unders your control. If you are actually the one hosting the site, you should be able to do this, however, if a second party hosts your site, they may not allow you to do that.

    Another possibility is making some web-page that collects info from the other sites and makes a report type of page for you. This assumes that on each page, you don't necessarily need to print out the entire page, but rather are attempting to pick out certain pieces of info from each site (eg stoke quote, price of a particular item, top sales items, etc). Basically, since you said the pages don't change, just the info in them, I'm assuming that means that their structure doesn't change either (or at least not on a regular basis). Thus you could write a script that would open their site in a new frame / window and then call something like:
    Code:
    opener.document.getElementById('myTextBox').value = otherSite.document.getElementById('theirTextBox').value;
    The script would then open the next site, get their info, etc. When the script is finished, you'd only have your page containing all of the revevant info to print out.
    If you want answers, write a smart question.

    Yes, someone probably does know how...

    Oh, and if you want to learn, STFW!

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah, you could do some screen scraping using a serverside lingo like say PHP, collate the results into a report and export to a variety of formats, then print them off.
    *keep it simple (TM)

  • #9
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I really like the idea of picking info out of every page; that would actually be preferable, as after I'm printing all of these out, I'm going through and making calculations based on what the pages contain. If I could pull data out, my life would be much, much easier (and easier yet if it was possible to export things to excel). The structure does remain unchanged. However, this data is not in a text box, it is just in a table (it's geological data, such as reservoir levels and river flows, pulled from USGS and NOAA sites). I suppose there should be a way to find the data, but I don't think I'm proficient enough in JS to do such a thing. Also, I am NOT running this off any type of server. I'm just using it as a tool on a local computer to make it easier to pull data from these internet sites; so any restrictions or complications from web servers can be disregarded.

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    To have more control and no strict security, look into HTAs.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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