在一个js文件里远程调用jquery.js会在ie8下的一个奇怪问题_javascript技巧: 代码如下: function include(path){ var a=document.createElement(script); a.type = text/javascript; a.src=path; var head=document.getElementsByTagName(head)[0]; head.appendChild
导读在一个js文件里远程调用jquery.js会在ie8下的一个奇怪问题_javascript技巧: 代码如下: function include(path){ var a=document.createElement(script); a.type = text/javascript; a.src=path; var head=document.getElementsByTagName(head)[0]; head.appendChild
代码如下: function include(path){ var a=document.createElement("script"); a.type = "text/javascript"; a.src=path; var head=document.getElementsByTagName("head")[0]; head.appendChild(a); } include("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js")
function include(path){ var a=document.createElement("script"); a.type = "text/javascript"; a.src=path; //if (a.readStatus == 200) { var head=document.getElementsByTagName("head")[0]; head.appendChild(a); //} } include("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js") script>
$(function(){ function sendData(url, callback){ if(!url || typeof url !== 'string'){ return; } url += (url.indexOf('?') > 0 ? '&' : '?') + 'windowname=true'; var frame = $('').appendTo("body"); var state = 0; var clear = function(){ try{ frame[0].contentWindow.document.write('');//清空iframe的内容 frame[0].contentWindow.close();//避免iframe内存泄漏 frame.remove();//删除iframe }catch(e){} }; var getData = function(){ try{ var data = frame[0].contentWindow.name; }catch(e){} clear(); if(callback && typeof callback === 'function'){ callback(data); } }; frame.bind('load', function(){ if(state === 1){ getData(); } else if(state === 0){ state = 1; frame[0].contentWindow.location = "none.html"; } }); frame[0].src = url; } //应用: var testurl = 'http://www.jb51.cn/test.html'; $("button").click(function(){ sendData( testurl ,function(result){ var fishDiv = $("#oldFish"); fishDiv.html( "你获取的数据是:"+result ); }) }) }) script>
Dev By 素材下载 & 桦
参考:脚本之家
在一个js文件里远程调用jquery.js会在ie8下的一个奇怪问题_javascript技巧
在一个js文件里远程调用jquery.js会在ie8下的一个奇怪问题_javascript技巧: 代码如下: function include(path){ var a=document.createElement(script); a.type = text/javascript; a.src=path; var head=document.getElementsByTagName(head)[0]; head.appendChild