Use JavaScript and registry scripts to right-click and add selected text to the favorites web page

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.