Flash控件的自动激活

1. 在中间加入objectSwap.js
<script src='objectSwap.js' type='text/javascript'>
2. falsh控件部分 to the object tag
具体参考见:http://blog.deconcept.com/swfobject/

object代码如下:

js 代码
  1. /* ObjectSwap - Bypasses the new ActiveX Activation requirement in Internet Explorer by swapping existing ActiveX objects on the page with the same objects. Can also be used for Flash version detection by adding the param:  
  2. <param name="flashVersion" value="8" /> to the object tag.  
  3.  
  4. Author: Karina Steffens, www.neo-archaic.net  
  5. Created: April 2006  
  6. Changes and bug fixes: May 2006  
  7. Bug fixes: June 2006  
  8. Changes: October 2006 (Included Opera9 and excluded IE5.5)  
  9. */  
  10.   
  11. //Check if the browser is InternetExplorer, and if it supports the getElementById DOM method   
  12. var ie = (document.defaultCharset && document.getElementById && !window.home);   
  13. var opera9 = false;   
  14. if (ie){   
  15.     //Check for ie 5.5 and exclude it from the script   
  16.     var ver=navigator.appVersion.split("MSIE")   
  17.     ver=parseFloat(ver[1])   
  18.     ie = (ver >=6)   
  19. }else if (navigator.userAgent.indexOf("Opera")!=-1) {   
  20.     //Check for Opera9 and include it in the ObjectSwap   
  21.     var versionindex=navigator.userAgent.indexOf("Opera")+6   
  22.     if (parseInt(navigator.userAgent.charAt(versionindex))>=9)   
  23.     opera9 = true;   
  24. }   
  25. //Perform ObjectSwap if the browser is IE or Opera (if not just check flashVersion)   
  26. var oswap = (ie || opera9)   
  27.   
  28. //Hide the object to prevent it from loading twice   
  29. if (oswap){   
  30.     document.write ("<style id='hideObject'> object{display:none;} </style>");   
  31. }   
  32.   
  33. /*Replace all flash objects on the page with the same flash object,   
  34. by rewriting the outerHTML values  
  35. This bypasses the new IE ActiveX object activation issue*/  
  36. objectSwap = function(){   
  37.     if (!document.getElementsByTagName){   
  38.         return;   
  39.     }   
  40.     //An array of ids for flash detection   
  41.     var stripQueue = [];   
  42.     //Get a list of all ActiveX objects   
  43.     var objects = document.getElementsByTagName('object');   
  44.     for (var i=0; i<objects.length; i++){              
  45.         var o = objects[i];    
  46.         var h = o.outerHTML;   
  47.         //The outer html omits the param tags, so we must retrieve and insert these separately   
  48.         var params = "";   
  49.         var hasFlash = true;   
  50.         for (var j = 0; j<o.childNodes.length; j++) {   
  51.             var p = o.childNodes[j];   
  52.             if (p.tagName == "PARAM"){   
  53.                 //Check for version first - applies to all browsers   
  54.                 //For this to work, a new param needs to be included in the object with the name "flashVersion" eg:   
  55.                 //<param name="flashVersion" value="7" />   
  56.                 if (p.name == "flashVersion"){   
  57.                     hasFlash = detectFlash(p.value);   
  58.                     if (!hasFlash){   
  59.                         //Add the objects id to the list (create a new id if there's isn't one already)   
  60.                         o.id = (o.id == "") ? ("stripFlash"+i) : o.id;   
  61.                         stripQueue.push(o.id);   
  62.                         break;   
  63.                     }   
  64.                 }    
  65.                 params += p.outerHTML;                
  66.             }   
  67.         }      
  68.         if (!hasFlash){   
  69.             continue;   
  70.         }          
  71.         //Only target internet explorer   
  72.         if (!oswap){   
  73.             continue;   
  74.         }    
  75.         //Avoid specified objects, marked with a "noswap" classname   
  76.         if (o.className.toLowerCase().indexOf ("noswap") != -1){   
  77.             continue;   
  78.         }          
  79.         //Get the tag and attributes part of the outer html of the object   
  80.         var tag = h.split(">")[0] + ">";               
  81.         //Add up the various bits that comprise the object:   
  82.         //The tag with the attributes, the params and it's inner html   
  83.         var newObject = tag + params + o.innerHTML + " </OBJECT>";     
  84.         //And rewrite the outer html of the tag    
  85.         o.outerHTML = newObject;   
  86.     }   
  87.     //Strip flash objects   
  88.     if (stripQueue.length) {   
  89.         stripFlash(stripQueue)   
  90.     }   
  91.     //Make the objects visible again   
  92.     if (oswap){   
  93.         document.getElementById("hideObject").disabled = true;   
  94.     }   
  95. }   
  96.   
  97. detectFlash = function(version){   
  98.     if(navigator.plugins && navigator.plugins.length){   
  99.         //Non-IE flash detection.   
  100.         var plugin = navigator.plugins["Shockwave Flash"];   
  101.         if (plugin == undefined){   
  102.             return false;   
  103.         }   
  104.         var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];   
  105.         return (Number(ver) >= Number(version))   
  106.     } else if (ie && typeof (ActiveXObject) == "function"){   
  107.     //IE flash detection.   
  108.         try{   
  109.             var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);   
  110.             return true;   
  111.         }   
  112.         catch(e){   
  113.             return false;   
  114.         }   
  115.     }   
  116.     //Catchall - skip detection   
  117.     return true;   
  118. }   
  119.   
  120. //Loop through an array of ids to strip   
  121. //Replace the object by a div tag containing the same innerHTML.   
  122. //To display an alternative image, message for the user or a link to the flash installation page, place it inside the object tag.     
  123. //For the usual object/embed pairs it needs to be enclosed in comments to hide from gecko based browsers.   
  124. stripFlash = function (stripQueue){   
  125.     if (!document.createElement){   
  126.         return;   
  127.     }   
  128.     for (var i=0; i<stripQueue.length; i++){   
  129.         var o = document.getElementById(stripQueue[i]);   
  130.         var newHTML = o.innerHTML;     
  131.         //Strip the comments   
  132.         newHTML = newHTML.replace(/<!--\s/g, "");   
  133.         newHTML = newHTML.replace(/\s-->/g, "");   
  134.         //Neutralise the embed tag   
  135.         newHTML = newHTML.replace(/<embed/gi, "<span");        
  136.         //Create a new div element with properties from the object   
  137.         var d = document.createElement("div");   
  138.         d.innerHTML = newHTML;   
  139.         d.className = o.className;   
  140.         d.id = o.id;   
  141.         //And swap the object with the new div   
  142.         o.parentNode.replaceChild(d, o);   
  143.     }   
  144. }   
  145.   
  146. //Initiate the function without conflicting with the window.onload event of any preceding scripts   
  147. var tempFunc = window.onload;   
  148. window.onload = function(){   
  149.     if (typeof (tempFunc) == "function"){   
  150.         try{   
  151.             tempFunc();   
  152.         } catch(e){}   
  153.     }   
  154.     objectSwap();   
  155. }   
  156.   
### 如何通过Flash按键对智能车进行参数调整 在智能车开发过程中,Flash按键通常用于进入下载模式或者执行特定的功能配置。以下是关于如何利用Flash按键完成参数调整的方法: #### Flash按键的作用 Flash按键的主要作用是在单片机启动时按下该键,使设备进入Bootloader模式[^1]。在此模式下,可以通过串口或其他通信方式加载新的固件或修改运行中的参数。 #### 参数调整流程 为了实现通过Flash按键调整参数的目的,开发者可以在程序设计阶段预留相应的接口逻辑。具体来说,可以按照以下思路构建功能框架: 1. **检测Flash按键状态** 在主循环中加入一段代码,用来判断Flash按键的状态变化(如短按、长按)。如果检测到按键被按下,则切换至参数调整界面或启用特殊模式。 ```c void check_flash_button() { static uint8_t button_state = 0; if (HAL_GPIO_ReadPin(FLASH_BUTTON_PORT, FLASH_BUTTON_PIN) == GPIO_PIN_RESET && !button_state) { // 如果按钮被按下 enter_config_mode(); // 进入配置模式函数 button_state = 1; // 更新按键状态标志位 } else if (HAL_GPIO_ReadPin(FLASH_BUTTON_PORT, FLASH_BUTTON_PIN) != GPIO_PIN_RESET) { button_state = 0; // 按钮释放后恢复默认状态 } } ``` 2. **定义参数存储位置** 使用内部EEPROM或外部存储芯片保存可调节的参数值。这些参数可能包括PID控制器系数、传感器校准数据以及电机速度设定等重要信息[^3]。 3. **提供用户交互手段** 当车辆处于停驻状态下并通过Flash按键激活调参功能之后,应该借助其他外设比如LCD显示屏显示当前设置项及其数值范围;同时允许使用者经由旋钮开关或者其他物理控件改变选项并确认提交更改后的结果回存至永久记忆单元之中。 4. **退出机制** 设定超时时间自动返回正常工作状态或是再次点击Flash按键手动结束本次操作过程。 #### 实际案例分享 以某款基于STM32系列MCU打造的小型自动驾驶平台为例,在其配套软件包里已经内置了一套完善的在线调试工具链支持上述提到的各项特性[^2]。用户只需遵循官方文档指引即可快速掌握整个系统的运作原理并且轻松达成个性化定制需求。 ```python def adjust_parameters(): while True: key_status = read_flash_key() if key_status['long_press']: show_menu_on_display() selected_param = get_user_selection() new_value = modify_parameter(selected_param) save_to_eeprom(new_value) elif key_status['short_press']: break ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值