www.webdeveloper.com
Results 1 to 4 of 4

Thread: Java Script Button

  1. #1

    Java Script Button

    Hi ^^,

    I have a website and I have a textarea for user to key in text, how can i create a "save as button" that allow user to save what they had key in .htm format?

    Thank you in advance.

  2. #2
    I find below code on internet

    Code:
    -- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
    <script>
    // CREDITS:
    // salar mehrabi
    // Copyright (c) 2003 Peter Gehrig and Urs Dudli. All rights reserved.
    // Permission given to use the script provided that this notice remains as is.
    // Additional scripts can be found at http://www.javakhafan.9f.com
    
    // IMPORTANT: 
    // If you add this script to a script-library or a script-archive 
    // you have to insert a link to http://www.javakhafan.9f.com 
    // right into the webpage where the script will be displayed.
    
    function doSaveAs(){
    	if (document.execCommand){
    		document.execCommand("SaveAs")
    	}
    	else {
    		alert("Save-feature available only in Internet Exlorer 5.x.")
    	}
    }
    </script>
    <form>
    <input type="button" value="Save This WebPage" onClick="doSaveAs()"
    </form>
    <br>
    <font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
    However, this code is only work in IE, It's not work in FireFox.
    I would appreciate if someone can give me an advice.

  3. #3
    Join Date
    Apr 2006
    Location
    Houston
    Posts
    1,374
    You really need to use a server side language and save to a database. OR if the text area is small enough you can save the info in a cookie (can save up to about 4000 characters)

    Also, why do you need a "Save As" ?

    What the users do with this information ?
    Will they need to reload this back into the text area ?
    Will they need to print this info ?

  4. #4
    Hi,

    Firstly, thank you for your reply.

    I'm create an html generator. You may take a look of this website www.malaysia-tractors.com for more detail.

    What the users do with this information ?
    As you can see in above website, you will notice that actually it's a website html generater.

    Why i need the "save as button?
    It's because i want to save the step of copying and pasting the content into notepad and save it as html format.

    Will they need to print this info ?
    NO.

    Hope to hear from you soon.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles