Microsoft KB Archive/318086

= FP2000: Sample JavaScript to Disable Text Selection in a Web Browser =

Article ID: 318086

Article Last Modified on 6/18/2005

-

APPLIES TO


 * Microsoft FrontPage 2000 Standard Edition

-



This article was previously published under Q318086



SUMMARY
This article provides sample JavaScript that you can add to a Web page to prevent a user from selecting text on your Web page. In other words, when a user drags the mouse over text on your Web page, nothing happens.

NOTE: This script also works in Netscape 6.0.



MORE INFORMATION
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.  In FrontPage, open the page to which you want to add the script. Click the HTML tab.  Type 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 the page and then preview it in your Web browser.

When you attempt to drag your mouse over the text, the text is not selected.

Additional query words: front page

Keywords: kbinfo KB318086

-

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

© Microsoft Corporation. All rights reserved.