Detect and right-click FLASH and js keys to shield and enable scrolling

Source: Internet
Author: User
The code is as follows: Copy code

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>
<Title> FLASH key detection and right-click shielding </title>
<Script type = "text/webpage effects" src = "swfobject. js"> </script>
</Head>

<Body>
<Div id = "flashcontent"> </div>
<Script type = "text/javascript">
Var so = new SWFObject ("FL.swf", "flash", "800", "600", "9", "# CCCCCC ");
So. addParam ("wmode", "opaque ");
So. write ("flashcontent ");
Function callFlash (){
// Alert (" ");
Document. getElementById ("flash"). onClick ();
  }
If (window. addEventListener ){
Window. addEventListener ("mousedown", function (e ){
If (e. button = 1) callFlash ();
// Right-click the block
If (e. button = 2 ){
If (e. stopPropagation) e. stopPropagation ();
If (e. preventDefault) e. preventDefault ();
If (e. preventCapture) e. preventCapture ();
If (e. preventBubble) e. preventBubble ();
    }
}, True );
} Else {
Document. getElementById ("flashcontent"). onmousedown = function (){
If (event. button = 4) callFlash ();
// Right-click the block
If (event. button = 2 ){
Document. oncontextmenu = function () {return false ;};
This. setCapture ();
This. onmouseup = function (){
This. releaseCapture ();
     }
    }
   }
  }
</Script>
</Body>
</Html>

Disable or enable scrolling based on whether the focus is on FLASH.

The code is as follows: Copy code

<Title> disable or enable scrolling based on whether the focus is on FLASH </title>
<Script. type = "text/javascript" src = "swfobject. js"> </script>
</Head>

<Body nload = "changeFocus ()">
<Input id = "outTxt" type = "text" value = "focus"/>
<Div id = "flashcontent"> </div>
</Body>
<Script. type = "text/javascript">
Function onMouseScroll (e ){
// Alert (document. activeElement = document. getElementById ("flash "));
Document. getElementById ("outTxt"). value = document. activeElement. id;
If (document. activeElement = document. getElementById ("flash ")){
If (e ){
If (e. preventDefault) e. preventDefault ();
} Else {
Return false;
  }
 }
}
Function changeFocus (){
If (window. addEventListener ){
Window. addEventListener ("DOMMouseScroll", onMouseScroll, true );
Window. onscroll = function () {document. getElementById ("flash"). blur ();};
} Else {
Document. onmousewheel = onMouseScroll;
 } 
}
Var so = new SWFObject ("focus.swf", "flash", "100%", "1000", "9 ");
So. write ("flashcontent ");
</Script>
</Html> [/


Swfobject. js
Save the following javascript code as swfobject. js.

The code is as follows: Copy code

If (typeof deconcept = "undefined") {var deconcept = new Object ();} if (typeof deconcept. util = "undefined") {deconcept. util = new Object ();} if (typeof deconcept. SWFObjectUtil = "undefined") {deconcept. SWFObjectUtil = new Object ();} deconcept. SWFObject = function (_ 1, id, w, h, _ 5, c, _ 7, _ 8, _ 9, _ a) {if (! Document. getElementById) {return;} this. DETECT_KEY = _? _ A: "detectflash"; this. skipDetect = deconcept. util. getRequestParameter (this. DETECT_KEY); this. params = new Object (); this. variables = new Object (); this. attributes = new Array (); if (_ 1) {this. setAttribute ("swf", _ 1);} if (id) {this. setAttribute ("id", id);} if (w) {this. setAttribute ("width", w);} if (h) {this. setAttribute ("height", h);} if (_ 5) {this. setAttribute ("version", new deconcept. playerVersion (_ 5. toString (). split (". ")));} This. installedVer = deconcept. SWFObjectUtil. getPlayerVersion (); if (! Window. opera & document. all & this. installedVer. major> 7) {deconcept. SWFObject. doPrepUnload = true;} if (c) {this. addParam ("bgcolor", c);} var q = _ 7? _ 7: "high"; this. addParam ("quality", q); this. setAttribute ("useExpressInstall", false); this. setAttribute ("doExpressInstall", false); var _ c = (_ 8 )? _ 8: window. location; this. setAttribute ("xiRedirectUrl", _ c); this. setAttribute ("redirectUrl", ""); if (_ 9) {this. setAttribute ("redirectUrl", _ 9) ;}}; deconcept. SWFObject. prototype = {useExpressInstall: function (_ d) {this. xiSWFPath =! _ D? "Expressinstall.swf": _ d; this. setAttribute ("useExpressInstall", true) ;}, setAttribute: function (_ e, _ f) {this. attributes [_ e] = _ f;}, getAttribute: function (_ 10) {return this. attributes [_ 10] ;}, addParam: function (_ 11, _ 12) {this. params [_ 11] = _ 12;}, getParams: function () {return this. params;}, addVariable: function (_ 13, _ 14) {this. variables [_ 13] = _ 14;}, getVariable: function (_ 15) {return this. variables [_ 15];}, getVariables: func Tion () {return this. variables;}, getVariablePairs: function () {var _ 16 = new Array (); var key; var _ 18 = this. getVariables (); for (key in _ 18) {_ 16 [_ 16. length] = key + "=" + _ 18 [key];} return _ 16;}, getSWFHTML: function () {var _ 19 = ""; if (navigator. plugins & navigator. mimeTypes & navigator. mimeTypes. length) {if (this. getAttribute ("doExpressInstall") {this. addVariable ("MMplayerType", "PlugIn"); this. setAttribute ("swf", this. xiSWF Path);} _ 19 = "<embed type =" application/x-shockwave-flash "src =" "+ this. getAttribute ("swf") + "" width = "" + this. getAttribute ("width") + "" height = "" + this. getAttribute ("height") + "" style = "" + this. getAttribute ("style") + ""; _ 19 + = "id =" "+ this. getAttribute ("id") + "" name = "" + this. getAttribute ("id") + ""; var _ 1a = this. getParams (); for (var key in _ 1a) {_ 19 + = [key] + "=" "+ _ 1a [key] + """;} var _ 1c = this. getVariablePairs (). join ("&"); If (_ 1c. length> 0) {_ 19 + = "flashvars =" "+ _ 1c +" ";} _ 19 + ="/> ";} else {if (this. getAttribute ("doExpressInstall") {this. addVariable ("MMplayerType", "ActiveX"); this. setAttribute ("swf", this. xiSWFPath);} _ 19 = "<object id =" "+ this. getAttribute ("id") + "" classid = "clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" width = "" + this. getAttribute ("width") + "" height = "" + this. getAttribute ("height") + "" style = "" + this. getAttribute (" Style ") +" ">"; _ 19 + = "<param name =" movie "value =" "+ this. getAttribute ("swf") + ""/> "; var _ 1d = this. getParams (); for (var key in _ 1d) {_ 19 + = "<param name =" "+ key +" "value =" "+ _ 1d [key] +" "/> ";} var _ 1f = this. getVariablePairs (). join ("&"); if (_ 1f. length> 0) {_ 19 + = "<param name =" flashvars "value =" "+ _ 1f +" "/> ";} _ 19 + = "</object>";} return _ 19;}, write: function (_ 20) {if (this. getAttribute ("useExpressInstall") {var _ 21 = new decon Cept. PlayerVersion ([6, 0, 65]); if (this. installedVer. versionIsValid (_ 21 )&&! This. installedVer. versionIsValid (this. getAttribute ("version") {this. setAttribute ("doExpressInstall", true); this. addVariable ("MMredirectURL", escape (this. getAttribute ("xiRedirectUrl"); document. title = document. title. slice (0, 47) + "-Flash Player Installation"; this. addVariable ("MMdoctitle", document. title) ;}} if (this. skipDetect | this. getAttribute ("doExpressInstall") | this. installedVer. versionIsValid (this . GetAttribute ("version") {var n = (typeof _ 20 = "string ")? Document. getElementById (_ 20): _ 20; n. innerHTML = this. getSWFHTML (); return true;} else {if (this. getAttribute ("redirectUrl ")! = "") {Document. location. replace (this. getAttribute ("redirectUrl") ;}} return false ;}}; deconcept. SWFObjectUtil. getPlayerVersion = function () {var _ 23 = new deconcept. playerVersion ([0, 0]); if (navigator. plugins & navigator. mimeTypes. length) {var x = navigator. plugins ["Shockwave Flash"]; if (x & x. description) {_ 23 = new deconcept. playerVersion (x. description. replace (/([a-zA-Z] | s) + /,""). replace (/(s + r | s + B [0-9] + )/,". "). sp Equals (". ") ;}} else {if (navigator. userAgent & navigator. userAgent. indexOf ("Windows CE")> = 0) {var axo = 1; var _ 26 = 3; while (axo) {try {_ 26 ++; axo = new ActiveXObject ("ShockwaveFlash. shockwaveFlash. "+ _ 26); _ 23 = new deconcept. playerVersion ([_ 26,0, 0]);} catch (e) {axo = null ;}} else {try {var axo = new ActiveXObject ("ShockwaveFlash. shockwaveFlash.7 ");} catch (e) {try {var axo = new ActiveXObject (" ShockwaveFlash. shockwaveFlash.6 "); _ 2 3 = new deconcept. playerVersion ([6, 0, 21]); axo. allowScriptAccess = "always";} catch (e) {if (_ 23. major = 6) {return _ 23;} try {axo = new ActiveXObject ("ShockwaveFlash. shockwaveFlash ");} catch (e) {}} if (axo! = Null) {_ 23 = new deconcept. playerVersion (axo. getVariable ("$ version "). split ("") [1]. split (",") ;}}return _ 23 ;}; deconcept. playerVersion = function (_ 29) {this. major = _ 29 [0]! = Null? ParseInt (_ 29 [0]): 0; this. minor = _ 29 [1]! = Null? ParseInt (_ 29 [1]): 0; this. rev = _ 29 [2]! = Null? ParseInt (_ 29 [2]): 0 ;}; deconcept. playerVersion. prototype. versionIsValid = function (fv) {if (this. major <fv. major) {return false;} if (this. major> fv. major) {return true;} if (this. minor <fv. minor) {return false;} if (this. minor> fv. minor) {return true;} if (this. rev <fv. rev) {return false;} return true;}; deconcept. util = {getRequestParameter: function (_ 2b) {var q = document. location. search | document. location. hash; if (_ 2b = null) {r Eturn q;} if (q) {var _ 2d = q. substring (1 ). split ("&"); for (var I = 0; I <_ 2d. length; I ++) {if (_ 2d [I]. substring (0, _ 2d [I]. indexOf ("=") = _ 2b) {return _ 2d [I]. substring (_ 2d [I]. indexOf ("=") + 1) ;}} return "" ;}}; deconcept. SWFObjectUtil. cleanupSWFs = function () {var _ 2f = document. getElementsByTagName ("OBJECT"); for (var I = _ 2f. length-1; I> = 0; I --) {_ 2f [I]. style. display = "none"; for (var x in _ 2f [I]) {if (typeof _ 2f [I] [x] = "function ") {_ 2f [I] [x] = function () {};}}}; if (deconcept. SWFObject. doPrepUnload) {if (! Deconcept. unloadSet) {deconcept. SWFObjectUtil. prepUnload = function () {__ flash_unloadHandler = function () {};__ flash_savedUnloadHandler = function () {}; window. attachEvent ("onunload", deconcept. SWFObjectUtil. cleanupSWFs) ;}; window. attachEvent ("onbeforeunload", deconcept. SWFObjectUtil. prepUnload); deconcept. unloadSet = true ;}} if (! Document. getElementById & document. all) {document. getElementById = function (id) {return document. all [id] ;};} var getQueryParamValue = deconcept. util. getRequestParameter; var FlashObject = deconcept. SWFObject; var SWFObject = deconcept. SWFObject;

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.