8月302018
检测当前网页,并加载返回JQuery
#includeExample() Func Example() Local $oIE = _IECreate("www.autoitx.com") Local $jQuery = _jQuerify($oIE) MsgBox(0, "版本", "当前 jQuery 版本: " & $jQuery.fn.jquery) EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ;来源: AU3的英文官方站 ;我也转载过来的. 只是把下面的 做了一下 中文说明. by:绿色风 ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) ;返回JQ对象 Local $jsEval, $jQuery, $otherlib = False ; 创建个对JS函数的引用 $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ; 判断 网页中是否已加载 jQuery ,没有就 加载一个的 了 If $jsEval("typeof jQuery=='undefined'") Then ; 检测 $ 符号是否被其它库占用 If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; 需要加载自己磁盘中的 用这 (快去下载一个去) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; ;需要在线下载 用这 $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery ;返回JQ对象 EndFunc ;==>_jQuerify
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!
感谢!