Example: For specific functions, please see the relevant usage introduction in "Woi Blog ( http://www.woiblog.com )"!
1. The function to be implemented is to add a right-click shortcut to the browser to submit the selected web page or image content! The example application is in the blog program, that is, when you are logged in, you can see better news or pictures when browsing the web! You can select the content --> right-click and "Add to My Web Excerpts" will pop up. At this time, an IE window will pop up, which will automatically add the webpage title to the corresponding title content of the form, and the selected content to the corresponding content items, as well as references. URL, etc!
2. Now let’s take a look at how this function is implemented!
First we use a text editor to write:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt]
[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExtAdd this page to my web excerpt]
@=" http://www.woiblog.com/UserManage/addblog.asp "
. Save it as a .REG file, that is, write the registry key to add the right-click menu
http://www.woiblog.com/UserManage/addblog.asp and process the page source file as follows:
<html>
<head>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
<title></title>
</head>
<body lang="zh-CN">
<form id=form1 action="User_Post_Blog2.asp" method="post">
<P>
<input type="hidden" name="title" id=title1>
<input type="hidden" name="url" id=url1>
<input type="hidden" name="js" id=js1>
<TEXTAREA id=content1 style="DISPLAY: none" name="content"></TEXTAREA> </P>
</form>
</body>
</html>
<script language="Javascript">
var oWin = external.menuArguments;
var oDoc = oWin.document;
var titlestr;
var start, end;
var getzy;
start = end = -1;
titlestr = oWin.document.selection.createRange().text;
for( var i = 0; i < titlestr.length; i++ )
{
if(start == -1)
if( titlestr.charAt( i ) == 'n' || titlestr.charAt( i ) == 'r' )
continue;
else
start = i;
else if( titlestr.charAt( i ) == 'n' || titlestr.charAt( i ) == 'r' )
{
end = i;
break;
}
}
if( start != -1 && end != -1 && start < end )
form1.title1.value = oDoc.title;
else
form1.title1.value = oDoc.title;
for( var i = 0; i < oDoc.images.length; i++ )
{
oDoc.images( i ).src = oDoc.images( i ).src;
}
for( var i = 0; i < oDoc.links.length; i++ )
{
oDoc.links( i ).href = oDoc.links( i ).href;
}
form1.url1.value = oDoc.URL;
getzy = oDoc.selection.createRange().text;
form1.js1.value = getzy.substr(0, 250)+"...";
form1.content1.innerText = oWin.document.selection.createRange().htmlText;
form1.submit();
</script>
I believe many people understand it. The above is an ordinary form, and the following is a script. The key lies below.
oDoc.title Web page title
oDoc.URL web address
getzy = oDoc.selection.createRange().text; 'Get the selected content in text form
form1.js1.value = getzy.substr(0, 250)+"..."; 'Get the first 250 characters, ending with..., as an introduction
form1.content1.innerText = oWin.document.selection.createRange().htmlText; Get the selected content in HTML mode
form1.submit(); Automatically submit the form to the ACTION in the FORM: User_Post_Blog2.asp
So far, we have obtained the information! After that, it’s normal ASP form processing!
For VALUE like title, use value=<%=request("title")%>
Just move the rest as it is!
Source: Fifth Network ( http://www.d5web.com ) Please indicate when reprinting