Results 1 to 2 of 2

Thread: Get text from a webpage

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    53

    Get text from a webpage

    Can you help me to make a button that when pressed will copy all the contents as when you right click on a webpage and click select all and copy. If I am running the program while i am viewing a webpage and then i click the button I won't all the contets of that webpage i am viewing to be copied into the clipboard.

    Just like this i did it to this page as an example
    -----------------------------------------------------------------------------

    VB Wire News
    Programming Microsoft Visual Basic .NET Reviewed
    FolderView ActiveX Control 4.3 released
    Html TextBox V2.0 - New Version, special pricing
    Code-Express released to the public!
    SMS Center




    Search the forums:




    VBForums.com > Visual Basic > ASP, VB Script, Internet and Network Development


    Post New Thread
    Logged in user: evanj [logout]
    Subject:
    Message Icon:
    No icon

    vB Code [help]
    Normal Mode
    Enhanced Mode SIZEsmall large huge FONTArial Times Courier Century COLOR sky blue royal blue blue dark-blue orange orange-red crimson red firebrick dark red green limegreen sea-green deeppink tomato coral purple indigo burlywood sandy brown sienna chocolate teal silver

    Close Current Tag
    Close All Tags

    Message:
    See Forum Rules (below) for
    more information about what
    codes you are allowed to use
    in your posts.

    Smilies




    Can you help me to make a button that when pressed will copy all the contents as when you right click on a webpage and click select all and copy. If I am running the program while i am viewing a webpage and then i click the button I won't all the contets of that webpage i am viewing to be copied into the clipboard.
    [check message length]

    Options: Automatically parse URLs: automatically adds and around internet addresses.
    Email Notification: emails sent to you whenever someone replies. Only registered users are eligible.
    Disable Smilies in This Post
    Show Signature: include your profile signature. Only registered users may have signatures.
    Attach file:
    Maximum size: 105360 bytes
    Valid file extensions: gif jpg png txt zip bas cls frm c h cpp ctl frx asp bmp
    Post a poll: Yes! post a poll
    Number of options initally: (Maximum: 10)




    Forum Rules:
    You may post new threads
    You may post replies
    You may post attachments
    You may edit your posts HTML code is OFF
    vB code is ON
    Smilies are ON
    [IMG] code is ON



    VB Forums - VB Wire
    Feedback



    Copyright 2003 Jupitermedia Corporation All Rights Reserved.
    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.
    Acceptable Use Policy



    Powered by vBulletin v2.2.9 - Copyright Jelsoft Enterprises Limited 2000 - 2002

    ---------------------------------------------------------------------------------

    Yeah so can I have a little program which will do this for me copy into the clipboard.

    Thanx for your time

    Goday
    Evan

  2. #2
    Hyperactive Member Anglo Saxon's Avatar
    Join Date
    Mar 2002
    Location
    Durham, UK
    Posts
    259
    Try this page :

    Code:
    <html>
    <head>
        <title>Untitled</title>
    <script>
     function SelectAndCopy() {
        var AllText = document.body.createTextRange();
        AllText.select();
    	AllText.execCommand("Copy");
    }
    </script>
    </head>
    <body>
    <!--START OF EXAMPLE TEXT FOR SELECTION-->
    <a href="#" onClick="SelectAndCopy(); return false">Click to select all text and copy to the clipboard</a>
    <pre>
    MSDN Home >  MSDN Library >  HTML and Dynamic HTML >  Reference >  Methods  select Method  Internet 
    Development Index 
    --------------------------------------------------------------------------------
    Makes the selection equal to the current object. 
    
    Syntax
    
    object.select()
    Return Value
    
    No return value.
    
    Remarks
    
    When applied to a TextRange object, the select method causes the current object to be highlighted. 
    The following function uses the findText method to set the current object to the text in the TextRange object. 
    The function assumes an element that contains the text string "text here". 
    
    function TextRangeSelect() {
        var r = document.body.createTextRange();
        r.findText("text here");
        r.select();
    }
    
    
    When applied to a controlRange collection, the select method produces a shaded rectangle around the elements in 
    the controlRange. The following function uses the add method to set the current object to an element in the 
    controlRange collection. The function assumes an element with an id of "aaa". 
    
    function ControlRangeSelect() {
        var r = document.body.createControlRange();
        r.add(document.all.aaa);
        r.select();
    }
    
    
    This feature might not be available on non-Microsoft. Win32. platforms. For the latest information about Microsoft 
    Internet Explorer cross-platform compatibility, see article Q172976 in the Microsoft Knowledge Base.
    
    Standards Information
    
    This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 . 
    
    Applies To
    
    [ Object Name ] 
    Platform Version 
    Win16:  
    Win32:  
    WinCE:  
    Unix:  
    Mac:  
    Version data is listed when the mouse hovers over a link, or the link has focus. 
    TextRange, controlRange 
    Move the mouse pointer over an element in the Applies To list to display availability information for the listed 
    platforms. 
    
    Contact Us   |  E-Mail this Page   |  MSDN Flash Newsletter  
    ) 2002 Microsoft Corporation. All rights reserved.   Terms of Use  Privacy Statement   Accessibility  
    </pre>
    <!--END OF EXAMPLE TEXT FOR SELECTION-->
    </body>
    </html>
    ---
    Anglo Saxon

Posting Permissions

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



Click Here to Expand Forum to Full Width