jQuery的getScript与原生js动态生成script,前者无效,后者有效

我在项目(在谷歌扩展程序)中运行这样一段代码
$.getScript("./script/sec.js",function(){
alert(1);
});
但是无效,用原生js
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = './script/sec.js'; //填自己的js路径
document.body.appendChild(script);
有效
另外,我把项目放在本地虚拟服务器测试的时候,这两种方法都是有效的。
所以我想知道差别在哪,是不是script添加的位置不同,我想知道jq的getScript
方法生成的script标签在代码中哪个位置。像是js的documentd.body.appendChild(script)在body标签的下方,求大神赐教!!!

1个回答

原理和你那个差不多,但是jqury是往head中插入script,不是body,并且会增加时间戳防止缓存。

不懂你的有效是什么歌一首。。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
jquery中getScript()的用法详解,从一个远程js文件中读取数据

第一个html文件: ``` <html> <head> <script type="text/javascript" src="jquery-2.1.3.js"></script> $.getScript("shuj.js",function(){alert("aaaaa");}) </head> </html> ``` js文件: ``` (function(){ var a='aaa'; var w=[]; w['杭州']= [{ s1:'多云', s2:'多云', f1:'duoyun', f2:'duoyun', t1:'12', t2:'2', p1:'3-4', p2:'3-4', d1:'北风', d2:'北风' }, { s1:'晴', s2:'多云', f1:'qing', f2:'duoyun', t1:'10', t2:'1', p1:'≤3', p2:'≤3', d1:'东北风', d2:'东北风' }, { s1:'晴', s2:'多云', f1:'qing', f2:'duoyun', t1:'11', t2:'2', p1:'≤3', p2:'≤3', d1:'北风', d2:'北风' }]; var add={ now:'2015-01-16 16:28:55', time:'1421396935', update:'北京时间01月16日08:05更新', error:'0', total:'1' }; window.SWther={ w:w, add:add }; })( );//0 ``` 请问怎么去取js里面的值展现在html中

使用jQuery中的getScript()在FireFox中报告的Javascript错误“XML不能是整个程序”

<div class="post-text" itemprop="text"> <p>I'm having issues with browsers reporting a javaScript error on my page. Although the page is fully functional, I prefer not having javaScript errors as it looks bad to users.</p> <p>The error I'm getting in FF is:</p> <pre><code>Error: SyntaxError: missing } in XML expression Source File: http://localhost/resources/adagiotips.php Line: 14, Column: 4 Source Code: }); </code></pre> <p>I'm using the getScript() function in jQuery to target a php page which renders code containing javascript and html. I then use the output from this page to populate the inner html of a div. This is what I have on page 1:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ jQuery.getScript('/includes/showmehow_videolist.php?sort=recent&amp;type=desc', function(output){ jQuery("#apple").html(output); }); }); &lt;/script&gt; &lt;div id="apple"&gt;content will populate here&lt;/div&gt; </code></pre> <p>And on "showmehow_videolist.php" I have a php while loop which writes a list of jQuery functions and some html. The code looks something like this:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ &lt;?PHP $result4 = mysql_query("SELECT * FROM videos")or die(mysql_error()); while($row4 = mysql_fetch_array($result4)){ ?&gt; jQuery("#video_&lt;?=$row4['vid_id']?&gt;").fancybox({ 'width' : &lt;?=$new_width_parsed?&gt;, 'height' : &lt;?=$new_height_parsed?&gt;, 'autoScale' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'none', 'type' : 'iframe', 'scrolling' : 'no', 'overlayColor' : '#000', 'overlayOpacity' : 0.6 }); &lt;? }//end while ?&gt; }); //end document.ready function &lt;/script&gt; &lt;div&gt;some content&lt;/div&gt; </code></pre> <p>When I remove the javascript portion from page 2 I get a different error in FF:</p> <pre><code>Error: SyntaxError: XML can't be the whole program Source File: http://localhost/resources/adagiotips.php Line: 1136, Column: 6 Source Code: &lt;/div&gt; </code></pre> <p>Any ideas? Is the problem because I'm populating the innerhtml of a div with javascript ... from javascript? Like I said, everything works fine, its just a matter of understanding why the browser is telling me there is an error.</p> <p>Any help would be much appreciated, thanks.</p> <p>output of /includes/showmehow_videolist.php:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ jQuery("#video_82").fancybox({ 'width' : 782, 'height' : 720, 'autoScale' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'none', 'type' : 'iframe', 'scrolling' : 'no', 'overlayColor' : '#000', 'overlayOpacity' : 0.6 }); jQuery("#video_83").fancybox({ 'width' : 782, 'height' : 720, 'autoScale' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'none', 'type' : 'iframe', 'scrolling' : 'no', 'overlayColor' : '#000', 'overlayOpacity' : 0.6 }); jQuery("#video_84").fancybox({ 'width' : 782, 'height' : 720, 'autoScale' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'none', 'type' : 'iframe', 'scrolling' : 'no', 'overlayColor' : '#000', 'overlayOpacity' : 0.6 }); }); //end document.ready function &lt;/script&gt; &lt;div style="overflow-x:hidden; overflow-y: auto; height:350px; width:725px;" id="main_div_of_video_links"&gt; &lt;div class="tab1"&gt; &lt;div class="tab2"&gt; &lt;span class="h2_standard"&gt;5&lt;/span&gt; &lt;span class="sm"&gt;views&lt;/span&gt; &lt;/div&gt; &lt;div class="tab3"&gt; &lt;img src="/images/icon_video_sm.gif" alt="History - Show Me How Video!" /&gt; &lt;a id="video_181" href="../video_pop.php?id=181" class="newAStyle"&gt;Adagio OrderEntry History&lt;/a&gt; &lt;!--&lt;img src="/images/flame_sm.png" /&gt;--&gt; &lt;img src="/images/new_icon.png" /&gt; &lt;/div&gt; &lt;div class="tab4"&gt; &lt;span class="sm"&gt;&lt;em&gt;Added: &lt;/em&gt;Jul 23 2012&lt;/span&gt; &lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="tab1"&gt; &lt;div class="tab2"&gt; &lt;span class="h2_standard"&gt;5&lt;/span&gt; &lt;span class="sm"&gt;views&lt;/span&gt; &lt;/div&gt; &lt;div class="tab3"&gt; &lt;img src="/images/icon_video_sm.gif" alt="Alternate Price Lists - Show Me How Video!" /&gt; &lt;a id="video_165" href="../video_pop.php?id=165" class="newAStyle"&gt;Adagio Inventory Alternate Price Lists&lt;/a&gt; &lt;!--&lt;img src="/images/flame_sm.png" /&gt;--&gt; &lt;img src="/images/new_icon.png" /&gt; &lt;/div&gt; &lt;div class="tab4"&gt; &lt;span class="sm"&gt;&lt;em&gt;Added: &lt;/em&gt;Jul 13 2012&lt;/span&gt; &lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="tab1"&gt; &lt;div class="tab2"&gt; &lt;span class="h2_standard"&gt;1&lt;/span&gt; &lt;span class="sm"&gt;views&lt;/span&gt; &lt;/div&gt; &lt;div class="tab3"&gt; &lt;img src="/images/icon_video_sm.gif" alt="Special Prices - Show Me How Video!" /&gt; &lt;a id="video_166" href="../video_pop.php?id=166" class="newAStyle"&gt;Adagio OrderEntry Special Prices&lt;/a&gt; &lt;!--&lt;img src="/images/flame_sm.png" /&gt;--&gt; &lt;img src="/images/new_icon.png" /&gt; &lt;/div&gt; &lt;div class="tab4"&gt; &lt;span class="sm"&gt;&lt;em&gt;Added: &lt;/em&gt;Jul 13 2012&lt;/span&gt; &lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> </div>

jQuery getScript –语法错误

<div class="post-text" itemprop="text"> <p>I dynamically load a JavaScript file using jQuery's <code>$.getScript()</code> method. The FireFox console always tells me that there is a "syntax error" in the first line. However, the script proceeds to work just fine. The first line is nothing but</p> <pre><code>function SomeFunc (param) { </code></pre> <p>as it is the start of a class. Adding a dummy class to the beginning of the file, like this:</p> <pre><code>function Dummy () { return false; } </code></pre> <p>... it shows the syntax error for the first line (<code>function Dummy () {</code>). Does anyone know what's causing this?</p> <p>Thanks in advance!</p> </div>

jquery ajax getScript奇怪的问题

$.getScript("a.js", function() {alert(1)}); <br /> <br />如果a.js <br />alert("2"); <br />var dwsCalendar = { <br /> kkk : "十" <br />} <br />没错误 <br /> <br />如果a.js <br />alert("2"); <br />var dwsCalendar = { <br /> kkk : "二十" <br />} <br />就要出错 <br /> <br />加了中文好像就要出错。但十不知道为什么可以,有没有人试过这个问题。 <br /> <br />jquery类库为:jquery-1[1].3.1.js<br /><strong>问题补充:</strong><br />aninfeel 已经是一样的。可还是不行。

jQuery Ajax加载和getScript

<div class="post-text" itemprop="text"> <p>I'm trying to set up my site so that content in the main area is loaded via javascript (some pages take a while to render). However, I've run into a bit of a logical problem when using jQuery.load(), jQuery.getScript and jQuery.ajax().</p> <p>I need to be able to load certain javascript files via getScript so that I can use these functions etc inside the loaded content.</p> <ul> <li>index.php - The main file being displayed (also contains #loading)</li> <li>js/script.js - The file containing the load code</li> <li>js/*.js - Several javascript files I need to be able to use inside #maincontent after the load</li> <li>load.php - The file being loaded into #maincontent</li> </ul> <p>script.js:</p> <pre><code>$(document).ready(function() { $('#loading').fadeIn('fast'); $('#maincontent').load('load.php', function() { $('#loading').fadeOut('fast'); $('#maincontent').fadeIn('slow'); }); $('#navigation li a').click(function() { $('#maincontent').fadeOut('fast'); $.getScript('js/jquery.contextMenu-1.01.js'); $.getScript('js/jquery-1.5.1.min.js'); $.getScript('js/jquery-ui-1.8.12.custom.min.js'); $.getScript('js/jquery.qtip-2.0.0.min.js'); $.getScript('js/ajax.js'); $.ajax({ method: 'get', url: 'load.php', data: 'page=' + $(this).attr('rel'), beforeSend: function() { $('#loading').fadeIn('fast'); }, complete: function() { $('#loading').fadeOut('fast'); }, success: function(html) { $('#maincontent').fadeIn('slow'); $('#maincontent').html(html); } }); }); $.getScript('js/jquery.contextMenu-1.01.js'); $.getScript('js/jquery-1.5.1.min.js'); $.getScript('js/jquery-ui-1.8.12.custom.min.js'); $.getScript('js/jquery.qtip-2.0.0.min.js'); $.getScript('js/ajax.js'); }); </code></pre> <p>As you can see, I'm trying to load load.php first without any URL parameters and any interaction from the user. Although load.php is loaded correctly every time, the same can't be said for the javascript code. Sometimes it works, other times I have to refresh the page a few times before I get a clean console (no errors).</p> <p>The errors in the console suggest to me that the js code isn't loaded properly before it is being used inside load.php. This is especially true if load.php takes a while (tested with PHP sleep(5) function).</p> <p>Let me know if I need to clarify anything :)</p> </div>

jquery $ .getScript()..如何将外部js文件中的数据导入数组

<div class="post-text" itemprop="text"> <p>I try to put data into js file, through "jquery $.post" and "fwrite php", and get back that data into array. How to do that?</p> <p>here's the html:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="https://code.jquery.com/jquery-2.1.4.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $("#button").click(function() { if ($("#nameput").val() != "") { $.post("processing.php", { putname: $("#nameput").val() }); var arr = [$.getScript("talk.js")]; alert(arr[0]); } }) }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" id="nameput" /&gt; &lt;button id="button"&gt;send AJAX req&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here's the php, I name it "processing.php" :</p> <pre><code>&lt;?php $file = fopen("talk.js","a"); $text = $_POST["putname"]; fwrite($file,'"'.$text.'",'); fclose($file); ?&gt; </code></pre> <p>And "talk.js" will look like this :</p> <pre><code>"a","b","c", </code></pre> <p>Why I can't put that data from "talk.js" into array at " var arr = [$.getScript("talk.js")]; " as in html file above?</p> <p>Here's what I try after I read comments. I change the scirpt into this:</p> <pre><code>&lt;script&gt; $(document).ready(function() { $("#button").click(function() { if ($("#nameput").val() != "") { $.post("processing.php", { putname: $("#nameput").val() }, function() { $.getScript("talk.js", function(data) { var arr = data.split(","); alert(arr[0]); }) }) } }) }) &lt;/script&gt; </code></pre> <p>And php into this:</p> <pre><code>&lt;?php $file = fopen("talk.js","a"); $text = $_POST["putname"]; fwrite($file,$text); fclose($file); ?&gt; </code></pre> <p>But it still not work?</p> </div>

我可以在 Node.js 中使用 jQuery 吗?

<div class="post-text" itemprop="text"> <p>Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?</p> </div> <p>转载于:https://stackoverflow.com/questions/1801160/can-i-use-jquery-with-node-js</p>

Jquery通过外部JS文件动态加载Growler

<div class="post-text" itemprop="text"> <p>I'm trying to push growler notifications dynamically generated in a php file..</p> <p>Heres my main file.</p> <pre><code> jQuery(document).ready(function() { jQuery("#test").click( function () { jQuery.getScript("php/live_updates.php"); }); }); </code></pre> <p>and heres the <code>live_updates.php</code></p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function() { jQuery.jGrowl("One"); jQuery.jGrowl("Two"); jQuery.jGrowl("Three"); }); &lt;/script&gt; </code></pre> <p>Looking in my web console its getting the file but not running the growlers..</p> <p>Anyone got any ideas</p> </div>

vue中怎么在script(<script></script>)代码快中使用过滤器?

注意: 是在<script></script>代码快中使用,不是<template></template>中

script标签的src中如何放入多个js文件?

![图片说明](https://img-ask.csdn.net/upload/201704/10/1491792717_231423.png) 请问这是什么技术?如何实现?

向getScript()添加超时

<div class="post-text" itemprop="text"> <p>I'm using the <code>getScript()</code> JQuery method but could really do with adding a timeout. Some scripts don't come back as failed for a good 6-8 seconds, which is too long. </p> <p>Is this possible? </p> <p>I've searched a bit and no solutions have been forthcoming. </p> <p>Something like:</p> <pre><code>$.getScript(a + "/myspeed/MySpeedServer/mss/js") .done(function() { //do stuff }) .fail(function() { //do stuff }); .timeout(2000) </code></pre> </div>

405错误该怎么解决,使用Jquery书写代码

在提交表单数据的时候出现405错误,该怎么解决?![图片说明](https://img-ask.csdn.net/upload/201903/04/1551688515_856815.png)

为什么我在Hbuilder上面调用了jquery但无法使用

![图片说明](https://img-ask.csdn.net/upload/201911/03/1572794788_9970.png) 无法轮播,有没有大神给我讲一下

getScript函数工作,但没有得到一些CSS

<div class="post-text" itemprop="text"> <p>So every time I am loading my <code>getScript</code> function on ajax success some of the js are working some of it are not. but if i'm loading trying to load it on my footer.php it's working. but I need to load it dynamically since I am using ajax to load my pages and I need my js files to load everytime I change content and also it looks like my .js files aren't getting the css from the page. Here's my code to load the scripts.</p> <p><strong>JS</strong></p> <pre><code>var base_url = window.location.origin; if (window.location.pathname.split('/')[1] === 'music' || window.location.pathname.split('/')[1] === 'musicsystem') base_url = base_url + '/' + window.location.pathname.split('/')[1]; $(document).ready(function() { $.ajax({ async: false, url: base_url + '/dashboard/index', success: function(data) { var getScript = jQuery.getScript; jQuery.getScript = function(resources, callback) { var length = resources.length, handler = function() { counter++; }, deferreds = [], counter = 0, idx = 0; for (idx; idx &lt; length; idx++) { deferreds.push(getScript(resources[idx], handler)); } jQuery.when.apply(null, deferreds).then(function() { callback &amp;&amp; callback(); }); }; var scripts = [ base_url + "/assets/bower_components/jquery/dist/jquery.min.js", base_url + "/assets/bower_components/bootstrap/dist/js/bootstrap.min.js", base_url + "/assets/bower_components/jquery-ui/jquery-ui.min.js", base_url + "/assets/bower_components/datatables.net/js/jquery.dataTables.min.js", base_url + "/assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js", base_url + "/assets/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js", base_url + "/assets/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js", base_url + "/assets/plugins/jvectormap/jquery-jvectormap-world-mill-en.js", base_url + "/assets/bower_components/jquery-knob/dist/jquery.knob.min.js", base_url + "/assets/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js", base_url + "/assets/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js", base_url + "/assets/bower_components/jquery-slimscroll/jquery.slimscroll.min.js", base_url + "/assets/bower_components/fastclick/lib/fastclick.js", base_url + "/assets/dist/js/adminlte.min.js", base_url + "/assets/dist/js/pages/dashboard.js", base_url + "/assets/plugins/iCheck/icheck.min.js", base_url + "/assets/dist/js/demo.js", base_url + "/assets/js/dataTables.colReorder.min.js", base_url + "/assets/dist/js/clipboard.js", base_url + "/assets/js/audio.min.js", base_url + "/assets/js/config.js", base_url + "/assets/js/dropzone.js", base_url + "/assets/js/howler.js", base_url + "/assets/js/upload.js", base_url + "/assets/js/player.js", base_url + "/assets/js/songdraganddrop.js", base_url + "/assets/js/pitching.js", base_url + "/assets/js/share.js", base_url + "/assets/js/alertify.js", base_url + "/assets/bower_components/select2/dist/js/select2.full.min.js", base_url + "/assets/js/newscript.js" ]; $.getScript(scripts, function(data, textStatus) { $('#inside').html(data); }); } }); }); </code></pre> </div>

jquery怎样实现移除重复运行后台

在jquery树形菜单的某一文本框中进行了连续几次的修改,但我只想在后台执行最后一次,用jquery怎样实现。

与wordpress的jquery POST错误

<div class="post-text" itemprop="text"> <p>I'm trying to use POST to retrieve some scripts on a wordpress site but I'm getting the following error</p> <pre><code>Uncaught TypeError: Cannot call method 'post' of undefined </code></pre> <p>Basically I load an external javascript file which loads a couple of scripts, then calls back to a function on the original page to execute a POST call to retrieve some data. </p> <p>I've used this exact same script on a "regular" HTML based site, so I know it works elsewhere. jQuery is loaded as you can see, because I use .getScript to retrieve another file (which does load)</p> <p>Now for the function retrieve_window(); located on the template file.</p> <pre><code>//template file that initially loads &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script src="http://localhost/Project1/js/retrieve_scripts.js"&gt;&lt;/script&gt; &lt;div class="reserve_wrapper " id="resere_wrapper"&gt;&lt;/div&gt; &lt;script&gt; function retrieve_window(){ $.post("http://localhost/Project1/windows/serve_window",function(data) { $('#reserve_wrapper').html(data); display_window(); }); } &lt;/script&gt; </code></pre> <p>Here's the get_scritps file that is loaded</p> <pre><code>//retrieve_scripts.js jQuery(document).ready(function ($) { $.getScript("http://localhost/project1/js/date.js", function() { }); //this script loads retrieve_window(); //calls back to template file to make POST request }); </code></pre> <p>So basically the retrieve_window is a callback function to ensure the date.js script is properly loaded</p> </div>

Jquery在php文件中调用javascript

<div class="post-text" itemprop="text"> <p>I created an html page that shows different divs, i.e. weather forecast etc., for information purposes on my computer. As the page is supposed to run all day long I implemented jquery to realize a regular refresh of the elements. Therefore I've put the divs code into php-files that are being loaded on a regular basis (see code below). </p> <p>Before I implemented jquery all the divs were working perfectly fine. In total I am using 12 different divs and now 11 of them are still working fine using jquery. The one element that is not working is the 'Windfinder' element which is a widget for weather forecasting. When I am copying the script from the php-file to the div definition in the main document everything is working fine. But then I don't have any updates on the weather forecast. </p> <p><strong>Screen.html:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; Example &lt;/title&gt; &lt;meta name="viewport" content="initial-scale=1.0"&gt; &lt;meta charset="utf-8"&gt; &lt;style&gt; html, body { height: 100%; margin: 0; padding: 0; } #Datum { position: absolute; left: 1563px; top: 135px; z-index: 5; } #Windfinder { position: absolute; height: 180px; width: 600px; left: 760px; top: 0px; margin:0px 0 0 0px; } #Webcam1 { position: absolute; left: 765px; top: 370px; margin:0px 0 0 0px; z-index: 6; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript" src="jquery-2.1.4.js"&gt; &lt;/script&gt; &lt;div id="Windfinder"&gt;&lt;/div&gt; &lt;div id="Datum"&gt;&lt;/div&gt; &lt;div id="Webcam1"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready( function(){ $('#Windfinder').load('Windfinder.php'); $('#Datum').load('Datum.php'); $('#Webcam1').load('Webcam1.php'); refresh_niedrig(); refresh_mittel(); refresh_hoch(); }); function refresh_hoch() { setTimeout( function() { $('#Webcam1').fadeOut('slow').load('Webcam1.php').fadeIn('slow'); refresh_hoch(); }, 5000); } function refresh_mittel() { setTimeout( function() { $('#Windfinder').fadeOut('slow').load('Windfinder.php').fadeIn('slow'); refresh_mittel(); }, 10000); } function refresh_niedrig() { setTimeout( function() { $('#Datum').fadeOut('slow').load('Datum.php').fadeIn('slow'); refresh_niedrig(); }, 15000); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When I delete the script inside the Windfinder.php file and insert a simple word this is shown at the correct position in the loaded Screen.html file. So the problem seems to be about loading the script inside the php file via jquery. </p> <p><strong>Windfinder.php:</strong></p> <pre><code> &lt;script type="text/javascript" src="http://www.windfinder.com/widget/forecast/js/thalkirchen_muenchen?unit_wave=m&amp;unit_rain=mm&amp;unit_temperature=c&amp;unit_wind=kmh&amp;columns=3&amp;days=3&amp;show_day=1&amp;show_pressure=0&amp;show_waves=0"&gt; &lt;/script&gt; </code></pre> <p>I did a lot of research on this an can't find a solution. Can anybody help me with this? </p> <p>Edit: Entering the link directly into my browser I get the following: </p> <pre><code>var iframeCode = ['&lt;iframe id="wf-forecast-thalkirchen_muenchen" src="http://www.windfinder.com/widget/forecast/thalkirchen_muenchen?show_pressure=0&amp;unit_temperature=c&amp;show_day=1&amp;show_rain=1&amp;unit_rain=mm&amp;days=3&amp;unit_wind=kmh&amp;show_clouds=1&amp;show_wind=1&amp;show_temperature=1&amp;show_waves=0&amp;columns=3&amp;unit_wave=m', '" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" style="border: 0px; vertical-align: bottom;"&gt;&lt;/iframe&gt;']; host = location.hostname; if (host) { iframeCode.splice(1, 0, '&amp;domain=' + host); } document.writeln(iframeCode.join('')); var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent", eventer = window[eventMethod], messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; eventer(messageEvent, function(event) { if (event.origin == 'http://www.windfinder.com') { var widget = document.getElementById('wf-forecast-thalkirchen_muenchen'), data = event.data.split(':'), width = data[0], height = data[1]; widget.width = width; widget.height = height; } return this; }, false); </code></pre> <p>I tried two different approaches inside <code>&lt;script type="text/javascript"&gt; $(document).ready( function(){</code> part using jquery .getScript. Both did not work out for me. First approach: </p> <pre><code> $.getScript("http://www.windfinder.com/widget/forecast/js/thalkirchen_muenchen?unit_wave=m&amp;unit_rain=mm&amp;unit_temperature=c&amp;unit_wind=kmh&amp;columns=3&amp;days=3&amp;show_day=1&amp;show_pressure=0&amp;show_waves=0", function(data){ $('#Windfinder').html(data); }); </code></pre> <p>And Second Approach not using the direct url but the Windfinder.php file: </p> <pre><code> $.getScript('Windfinder.php', function(data){ $('#Windfinder').html(data); }); </code></pre> </div>

Extjs加载动态加载js文件

我有2个js文件一个在index.html通过script加载另外一个js需要通过第一个js里面的button点击加载。如何加载?有源码吗?关闭之后如何清除之前加载的js

如何让$ .getScript正常工作?

<div class="post-text" itemprop="text"> <p>I can see that the $.getScript bit of jquery would be handy once it's working, but it's the last little bit I'm having problems with. I'm suspecting the problem is caused by the way I'm loading JS files. How do I get this to work? My index.html is actually index.php and has very little between the body tags. I'm using jquery 1.7.1</p> <pre><code>&lt;body id="btLive"&gt; &lt;script&gt; buildInterfaces(); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>buildInterfaces() resides inside a document named layoutLoader.js. In that file, I have the following:</p> <pre><code>$(document).ready(function() { $('#hToggle').click(function() { aaa = "Not working."; $.getScript('test.js', function() { alert(aaa); }); toggleHoverPanel(); }); }); </code></pre> <p>As my test, test.js is in the same folder as layoutLoader.js and contains only the following:</p> <pre><code>aaa = "Successful Load." </code></pre> <p>When I click on the button hToggle, toggleHoverPanel takes place and I get no alert. If I place an alert after aaa="Not working."; I get the alert I expect, telling me it's not working. I have a number of items that I need to use this for, but for the life of me, I cannot get it to work. Help?</p> </div>

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

立方体线框模型透视投影 (计算机图形学实验)

计算机图形学实验 立方体线框模型透视投影 的可执行文件,亲测可运行,若需报告可以联系我,期待和各位交流

2019 AI开发者大会

2019 AI开发者大会

组成原理课程设计(实现机器数的真值还原等功能)

实现机器数的真值还原(定点小数)、定点小数的单符号位补码加减运算、定点小数的补码乘法运算和浮点数的加减运算。

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

软件测试2小时入门

软件测试2小时入门

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

计算机图形学-球的光照模型课程设计

计算机图形学-球的光照模型,有代码完美运行,有课程设计书

Linux常用命令大全(非常全!!!)

Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错。我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较短小但却功能强大。我将我了解到的命令列举一下,仅供大家参考: 系统信息 arch 显示机器的处理器架构 uname -m 显示机器的处理器架构 uname -r 显示正在使用的内核版本 d...

因为看了这些书,我大二就拿了华为Offer

四年了,四年,你知道大学这四年我怎么过的么?

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

fakeLocation13.5.1.zip

fakeLocation13.5.1 虚拟定位 ios13.5.1的最新驱动下载,iPhone/iPad免越狱虚拟定位工具Location-cleaned驱动已更新

UnityLicence

UnityLicence

Python可以这样学(第一季:Python内功修炼)

Python可以这样学(第一季:Python内功修炼)

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

土豆浏览器

土豆浏览器可以用来看各种搞笑、电影、电视剧视频

【数据结构与算法综合实验】欢乐连连看(C++ & MFC)案例

这是武汉理工大学计算机学院数据结构与算法综合实验课程的第三次项目:欢乐连连看(C++ & MFC)迭代开发代码。运行环境:VS2017。已经实现功能:开始游戏、消子、判断胜负、提示、重排、计时、帮助。

php+mysql学生成绩管理系统

学生成绩管理系统,分三个模块:学生,教师和管理员。 管理员模块:负责学生、老师信息的增删改;发布课程信息的增删改,以便让学生选课;审核老师提交的学生成绩并且打印成绩存档;按照课号查询每个课号的学生成绩

多功能数字钟.zip

利用数字电子计数知识设计并制作的数字电子钟(含multisim仿真),该数字钟具有显示星期、24小时制时间、闹铃、整点报时、时间校准功能

推荐24个国外黄色网站欣赏

在中国清朝,明黄色的衣服只有皇子才有资格穿,慢慢的黄色在中国就成了高贵的颜色。在人们的色彩印象中,黄色也表现为暂停。所以当你的网页设计采用黄色的时候,会让人们在你的网页前停留。 黄色,就像橙色和红色,黄色也是一个暖色。它有大自然、阳光、春天的涵义,而且通常被认为是一个快乐和有希望的色彩。黄色是所有色相中最能发光的颜色,给人轻快,透明,辉煌,充满希望的色彩印象。 黄色是一个高可见的色...

u-boot-2015.07.tar.bz2

uboot-2015-07最新代码,喜欢的朋友请拿去

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

学生成绩管理系统(PHP + MYSQL)

做的是数据库课程设计,使用的php + MySQL,本来是黄金搭配也就没啥说的,推荐使用wamp服务器,里面有详细的使用说明,带有界面的啊!呵呵 不行的话,可以给我留言!

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

C++语言基础视频教程

C++语言基础视频教程

玩转Python-Python3基础入门

玩转Python-Python3基础入门

相关热词 c# 局部 截图 页面 c#实现简单的文件管理器 c# where c# 取文件夹路径 c# 对比 当天 c# fir 滤波器 c# 和站 队列 c# txt 去空格 c#移除其他类事件 c# 自动截屏
立即提问