Based on jquery modifications, the following are all scripts
Copy Code code as follows:
Cross-word Search
var GLS = {};
Gls.startobj = null;
Gls.isdb = false;
Gls.allow = true;
Gls.isallow = function () {
if (Gls.allow) {
Gls.allow = false;
Alert (' Google search has been closed ');
}
else {
Gls.allow = true;
Alert (' Google search is open ');
}
};
Gls.dblclick = function () {
Gls.isdb = true;
};
Gls.mousedown = function (evt) {
EVT = (evt)? EVT: ((window.event)? Window.event: "");
if (evt) {
Gls.startobj = (evt.target)? Evt.target:evt.srcElement;
}
};
Gls.mouseup = function (evt) {
var obj;
var strlen;
EVT = (evt)? EVT: ((window.event)? Window.event: "");
if (evt) {
obj = (evt.target)? Evt.target:evt.srcElement;
strlen = window.getselection? Window.getselection (). toString (): Document.selection.createRange (). text;
}
var str = "";
if (obj.tagname!= "A" && obj.tagname!= "INPUT" && obj = = Gls.startobj &&! Gls.isdb && Gls.allow) {
if (Strlen.length > 0) {
str = strlen;
}
}
Gls.search (str, EVT);
Gls.isdb = false;
};
Gls.search = function (str, EVT) {
var obj = $ ("#GLSearch");
var sdivwidth = 88; Search box "Google search" width
if (str.tostring (). length > 0) {
var windowwidth; The width of the window
Get the width of the window
if (self.innerwidth) {
WindowWidth = Self.innerwidth;
else if (document.documentelement && document.documentElement.clientWidth) {
WindowWidth = Document.documentElement.clientWidth;
else if (document.body) {
WindowWidth = Document.body.clientWidth;
}
Obj.css ({' Display ': ' block ', ' position ': ' absolute ', ' zindex ': ' 10000 '});
var rx, Rx, WT;
if ($.browser.msie) {
WT = (Evt.clientx + sdivwidth)-windowwidth;
RY = Document.documentElement.scrollTop + evt.clienty;
RX = Document.documentElement.scrollLeft + evt.clientx;
RY = (Evt.clienty < 25)? RY + 5:ry-25;
RX = (WT > 0)? Rx-wt:rx + 5;
}
else {
var ST = (Document.documentElement.scrollTop > 0)? Document.documentElement.scrollTop:document.body.scrollTop;
WT = (Evt.pagex + sdivwidth)-windowwidth;
RY = ((evt.pagey-st) < 25)? Evt.pagey + 5:evt.pagey-25;
RX = (WT > 0)? Evt.pagex-wt:evt.pagex + 5;
}
Obj.css ("Top", RY);
Obj.css ("left", RX);
Obj.html ("<a class= ' gl_s ' target= ' _blank '" href= ' http://www.google.com/search?ie=UTF-8&oe=UTF-8&q= ') + encodeURIComponent (str) + "' >google search </a>");
}
else {
OBJ.CSS ("Display", "none");
}
};
Page load
$ (document). Ready (function () {
$ (document.body). Append ("<div id= ' Glsearch ' ></div>");
$ (document). MouseDown (Gls.mousedown). DblClick (Gls.dblclick). MouseUp (Gls.mouseup);
------------attached css/*search*/
A.gl_s{width:68px;height:20px;display:block;border:solid 1px #2b7ab7; line-height:20px;padding-left:18px;color:# 084f10;font-size:12px;font-weight:bold;background:url (search.gif) no-repeat Left;text-decoration:none;}
A.gl_s:link{filter:alpha (opacity=71);-moz-opacity:0.7;opacity:0.7;}
A.gl_s:hover{filter:alpha (opacity=100);-moz-opacity:1.0;opacity:1.0;} ----------Search.gif Pictures