Two days ago found a good site on the Internet, is used to do data collection (http://wolf.360doc.com ).
This website provides such a function to directly add the selected text to your favorites. At that time, it was amazing. Later I studied and found that using JavaScript and registry scripts can achieve this function.
The code for right-click to add a page to favorites is as follows (my favorite page is named rightClick. jsp ):
Copy codeThe Code is as follows: <Script LANGUAGE = "JavaScript">
If (external. menuArguments)
{
Var selText = "";
Var strTitle = escape(external.menuArguments.doc ument. title );
Var strURL = escape (external. menuArguments. location. href );
Var doc = external.menuArguments.doc ument;
If (doc. selection. type = "None") | (doc. selection. type = "none "))
{
Alert ("select the text and images to save on the webpage and add them to favorites! ");
}
Else
{
SelText = doc. selection. createRange (). text;
If (selText = "")
{
Alert ("select the text and images to save on the webpage and add them to favorites! ");
}
Else
{
External.menuArguments.document.exe cCommand ("Copy ");
Var objChild; // Window
Var reWork = new RegExp ('object', 'gi'); // Regular expression
ObjChild = window. open ("SaveMenu. jsp? Title = "+ strTitle +" & url = "+ strURL," objChild "," toolbar = no, menubar = no, resizable = yes, location = no, status = yes, z-look = yes, alwaysRaised = yes, scrollbars = no ");
If (! ReWork. test (String (objChild )))
Alert ("the article favorites page is blocked! \ R \ n Please set the interception pop-up window software you installed so that the current page is not blocked! ");
}
}
}
</Script>
</Html>
The text display Page code is as follows (my favorite page is named SaveMenu. jsp ): Copy codeThe Code is as follows: <HTML>
<HEAD>
<Title> network favorites </title>
<Script language = "JavaScript">
<! -- Hide me
Function Preloader ()
{
Var Editor1 = document. getElementById ('textbox ');
TextRange = Editor1.createTextRange ();
TextRange.exe cCommand ("Paste ");
}
-->
</Script>
</HEAD>
<Body vLink = "# 261cdc" link = "# 261cdc" leftMargin = "0" topMargin = "5" onload = "setTimeout ('preloader (); ', 1000 ); ">
<P title = "text box for network favorites"> text box for network favorites </p>
<Textarea name = "TextBox" id = "TextBox" style = "height: 300px; width: 100%;"> </textarea>
</Body>
</HTML>
The Registry script is as follows:Copy codeThe Code is as follows: Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ MenuExt]
[HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ MenuExt \ Localhost Test]
@ = "Http: // 10.1.1.19: 8080/test/rightClick. jsp"
If you are interested, try it on your own!