草庐IT

load_source

全部标签

javascript - attachEvent/addEventListener 到 Window onload/load - 首选方式

我有一个在页面加载时启动的脚本,我一直在使用下面的代码启动它:if(window.addEventListener){window.addEventListener('load',otherRelatedParts,false);}elseif(window.attachEvent){window.attachEvent('onload',otherRelatedParts);}但今天我尝试使用这样的自调用函数:(function(){otherRelatedParts();}())它似乎在所有浏览器中都有效,而且代码更少。这是将事件添加到窗口加载的首选方式吗?

javascript - 页面 Load 、 onload 和 $(document).ready() 之间的区别

我需要更详细地了解pageLoad、onload和$(document).ready()之间的区别我找到了答案,但我不是很清楚。答案就像ThereadyeventoccursaftertheHTMLdocumenthasbeenloaded,whiletheonloadeventoccurslater,whenallcontent(e.g.images)alsohasbeenloaded.TheonloadeventisastandardeventintheDOM,whilethereadyeventisspecifictojQuery.Thepurposeofthereadyeven

javascript - jQuery $(window).load 没有按预期工作

我今天在删除以前加载到我的Assets管道中但需要提取到部分以进行某些A/B测试的部分功能时遇到了一些没想到的事情。我正在使用bigVideo.js库在页面上加载全屏视频。今天,当我将代码提取到部分时,BigVideo.js开始加载错误的尺寸。部分加载低于我其余的javascriptAssets。我之前将代码封装在我的普通Assets管道中的匿名函数中。原始代码(有效)$(function(){(function(){varbgVid=new$.BigVideo({useFlashForFirefox:false})bgVid.show('http://videourl.com',{a

javascript - "JavaScript placed at the end of the document so the pages load faster"是吗?

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:Javascriptonthebottomofthepage?我在一些推特Bootstrap示例中看到了一条评论。它说JavaScriptplacedattheendofthedocumentsothepagesloadfaster这是真的吗??如果是,那么它是如何工作的??

javascript - 使用 Javascript 在浏览器中以编程方式打开 "View Source"HTML 窗口?

如何以编程方式打开“查看源代码”窗口(使用一些Javascript),就像在浏览器中右键单击并单击“查看源代码”一样?这可能吗? 最佳答案 您可以使用Firefox、Chrome和旧版IE支持的“查看源代码”URI模式。不需要JavaScript,只是您希望用户在源代码View中看到的页面的普通链接:viewWikipedia'shomepageHTMLsource更多信息:http://en.wikipedia.org/wiki/View-source 关于javascript-使用J

javascript - AMD 模块整形 : How to load only one JS function?

许多JavaScript库都有一个Builder工具,可以让您“塑造”您所依赖的库的哪些功能,无论是在客户端的下载带宽成本方面还是在隔离您实际需要的功能方面。例如,我喜欢sugar.js中的很多东西,但我根本不需要或不想处理片假名和平假名字符集。作为最简单的示例,我希望能够“塑造”sugar.js以仅导出string.isBlank()。是否有可用的工具为我执行此操作?EcmaScript委员会是否正在努力在未来的JavaScript版本中做这样的事情?是否有任何高级语言(如TypeScript和CoffeeScript)为此类“整形”提供隐藏支持?我可以通过monolinker在C#

javascript - Angular UI 路由器 : URL changed but view isn't loaded

我正在使用嵌套View开发我的UI-Router应用程序。我这样定义了一些状态:$stateProvider.state('parent',{url:"/parent",views:{'area1':{templateUrl:'parentView.html'},'area2':...//someotherareas+template}}).state('parent.child1',{url:"/child1",views:{'area1':{templateUrl:'child1View.html'},'area2':...//stillsomeotherareas,notchan

javascript - 卡斯珀JS : Why does my url change to about:blank when my page is loaded?

我是PhantomJS/CasperJS的初学者。我只想启动一个session并验证它是否正常。这是我的代码:varcasper=require('casper').create({verbose:true,logLevel:'debug',pageSettings:{loadImages:false,loadPlugins:false,userAgent:'Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/39.0.2171.71Safari/537.36Edge/12.0'}});ca

javascript - Chrome 扩展 : how to detect that content script is already loaded into a tab?

我的后台脚本中有以下代码:chrome.tabs.onUpdated.addListener(function(tabId,changeinfo,tab){if(changeinfo.status!=='complete')return;if(!matchesUrlFilters(tab.url))return;chrome.tabs.executeScript(tabId,{file:"jquery-1.7.1.min.js"},function(){chrome.tabs.executeScript(tabId,{file:"enhance.js"});});});但是,在某些情况

javascript - Firefox 扩展和 XUL : get page source code

我正在开发我的第一个Firefox扩展,为此我需要获得当前页面的完整源代码。我如何使用XUL做到这一点? 最佳答案 你需要一个xulbrowser将内容加载到的对象。将页面的“view-source:”版本加载到浏览器对象中,其方式与“ViewPageSource”菜单相同。请参阅chrome://global/content/viewSource.js中的函数viewSource()。该函数可以从缓存中加载,也可以不加载。内容加载后,原始来源由:varsource=browser.contentDocument.getElemen