Microsoft KB Archive/317330

= How to use FrontPage 2002 to prevent the selection of a text in a Web page =

Article ID: 317330

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft FrontPage 2002 Standard Edition

-



This article was previously published under Q317330



For a Microsoft FrontPage 2000 and Microsoft FrontPage 98 version of this article, see 318361.

IN THIS TASK

 * SUMMARY
 * How to Prevent Selection of Text in a Web Browser



SUMMARY
Use this step-by-step guide to disable the ability to select and copy text in your Web page when it is viewed in a Web browser. You can accomplish this task by including JavaScript code in the BODY element of your Web page. When the mouse pointer is dragged across the text in your Web page, the text is not selected.

NOTE: The JavaScript example in this article also works when you open your page in the Netscape 6.0 Web browser.

This procedure does not prevent someone from viewing the source code in the browser to copy the content.

back to the top

How to Prevent Selection of Text in a Web Browser
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets may appear as escaped HTML code. To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage.  Start FrontPage and open your Web page. Click the HTML tab.  Insert the following JavaScript code between the  and  tags. 

function disabletext(e){ return false }

function reEnable{ return true }

//if the browser is IE4+ document.onselectstart=new Function (&quot;return false&quot;)

//if the browser is NS6 if (window.sidebar){ document.onmousedown=disabletext document.onclick=reEnable }                    Save your Web page and then preview it in your Web browser.

If you now attempt to select the text by dragging the mouse pointer over the text, it is not selected.

The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

back to the top

Additional query words: select selecting copy copying highlight highlighting

Keywords: kbweb kbprogramming kbhowtomaster KB317330

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.