Options

How to create a download webpage button

DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
Does any one know how to create a button in HTML that down load the current webpage, rather than open it ?

What i want is to dynamicly create a webpage (see my script help thread)

and on that page have a button that will allow users to click to download/save the page as a text file.

idealy i dont want to use and client side scripting so it is complety portable, but if not some simple jave coded would be ok i supose. as long is it will work cross browser and OS.

Any ideas ?

Cheers


wondering if the folowwing code can help.

use LWP::Simple;

getstore( 'http://www.somehost.com/somepage.html',
'/home/Sarsamkar/somepage.html' );

DevilWAH
  • If you can't explain it simply, you don't understand it well enough. Albert Einstein
  • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.

Comments

  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    This is all using perl at the moment. Is it possible to get the webserver to save the page created localy as a text file using the perl code. Then I can just create a link to the file for the user to click.

    this is the way I would like to do it, but at the moment the only way I can see is to run the code once to create the webpage and a second time to create the txt file?
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Options
    DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
    I've seen it before where it puts code in like a text box and then has a copy button there. I don't know how they do it though.
    Decide what to be and go be it.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    ok bit more info
    below is the source code output from the script I wrote.

    what can I add at the bottom that will allow a user to save the page as a text file by clicking a button.

    what i wanted to do was add an html button that called a script to use the lwp::simple to capture the webpage as text. and then link to the file created to download it.

    does any one know how to call a script with an html button with out opening a seperate page? Still trying to do this all server side.


    my thoughts would be the button would be some thing like

    on click=

    <iframe src="html_intro.asp" width="0" height="0">
    ##"call the script to create the file"
    ## "download the txt file"
    </iframe>

    And the script would be simply
    {
    use lwp::simple
    getstore ( "/cgi-bin/scriptwriter.cgi" , "/cgi-bin/scripts/script.text" );
    }

    Could this work ?

    Cheers

    Aaron


    [FONT=Courier New][SIZE=3]<b><u>PORT PROVISIONING IMPLEMENTATION SCRIPT </b></u> <p> [/SIZE][/FONT]
    [FONT=Courier New][SIZE=3] [/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]=======================<br>GCM00026548 - 25/10/1976<br>=======================<p>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]========================= SRM00030698 ==============================<p>TMP engineer: Aaron &nbsp &nbsp Scripted on 24/10/1976<br>TPM Start time: 12:00 &nbsp &nbsp TPM End time: 12:50 &nbsp Time Worked: 50min<br>=========================================================================<p>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Server Name: loncdcas4bs43<br>Location: Croydon Data Center, Hall IT401<br>Rack: AC023<br>Digram: <br>ITSM ref: CHM003265648<br>=========================================================================<p>You can use the following show commands to display details for indivual ports.<p><b>On Switch <u>loncdc5sas45</u> use </b><br><br>sh int g1/2 status <br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]sh int g1/3 status <br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]<br><b>On Switch <u>loncdc5sas46</u> use </b><br><br>sh int g1/2 status <br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]<br><p>=========================================================================<p><b>Log on to Switch:</b> <u>loncdc5sas45</u><p>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]conf t <br><br><p>int g1/2<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]description loncdcas4bs43<br>switchport access vlan 34<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Speed Auto<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Duplex Auto<br>no shut<br>exit[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]<p>int g1/3<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]description loncdcas4bs43_ilo[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]<br>switchport access vlan 566<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Speed Auto<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Duplex Auto<br>no shut<br>exit[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]exit <p> sh int status <p> wr mem <p>VLAN 34 = Subnet 10.123.23.0/24<br>VLAN 566 = Subnet 10.23.23.0/24<br>=======================================================================================================<p><b>Log on to Switch:</b> <u>loncdc5sas46</u><p>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]conf t <br><br><p>int g1/2<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]description loncdcas4bs43<br>switchport access vlan 34<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Speed Auto<br>[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]Duplex Auto<br>no shut<br>exit[/SIZE][/FONT]
    [FONT=Courier New][SIZE=3]exit <p> sh int status <p> wr mem <p>VLAN 34 = Subnet 10.123.23.0/24<br>=======================================================================================================<p>[/SIZE][/FONT]
    [FONT=Courier New]Commenced at:<br>Completed at:<br>Completed by:<br>Successfull YES/NO<p>Script auto generated by web script[/FONT]
    
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    Devilsbane wrote: »
    I've seen it before where it puts code in like a text box and then has a copy button there. I don't know how they do it though.

    hold on thats a very good idea!!!

    if the script is written to a text box, that is in its self a form, then a second submit button to some perl code makes it simple to write the contents to a file and down load it!!

    I like it!

    DevilWAH
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    if only i could give you more rep :) thts a great idea devil and works perfect :)
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Options
    DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
    No problem, glad I could help.
    Decide what to be and go be it.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    Devilsbane wrote: »
    No problem, glad I could help.

    not sure if you saw but heres the code I used to pass the text box data to :)

    http://www.techexams.net/forums/off-topic/59688-script-repository.html#post500038
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
Sign In or Register to comment.