草庐IT

Simple-Kinect-viewer-that-writes-

全部标签

javascript - window.document.write 的 jQuery 等价物

有谁知道javascript中window.document.write('')的jQuery等价物?谢谢 最佳答案 这将在正文结束标记之前添加字符串“hello”。不完全是write的行为,但您可以对任何元素执行此操作以使内容出现在您想要的位置。$(document.body).append('hello');还可以使用prepend(content)和replaceWith(content)来满足您的所有插入需求! 关于javascript-window.document.write

javascript - Angular Testing : Spy a function that was executed on the initialize of a controller

我一直在尝试监视在Controller初始化时执行的函数,但测试总是失败。我一直在尝试执行$scope.$digest()但它不起作用,但是在控制台中,我看到该函数已被调用。我想不通,有人可以向我解释为什么它不起作用吗?代码笔示例:http://codepen.io/gpincheiraa/pen/KzZNbyControllerfunctionController($stateParams,$scope){$scope.requestAuthorization=requestAuthorization;if($stateParams.requestAuthorization===tr

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 - 开放层 3 : simple LineString example

我是OpenLayers的新手,我正在寻找在map上绘制线条的帮助,我一直在尝试各种不同帖子中关于绘制LineString的各种方法,但我无法让它工作!我只需要弄清楚如何在坐标之间画一条线。下面是一些我试过但没有用的代码:varpoints=[newol.geom.Point([78.65,-32.65]),newol.geom.Point([-98.65,12.65])];varfeatureLine=newol.Feature({geometry:newol.geom.LineString(points)});varsourceLine=newol.source.Vector({f

javascript - JSLint "document.write can be a form of eval"- 这是怎么回事?

我在JSLint中看到过这条消息...document.writecanbeaformofeval.并想知道到底是怎么回事?JSLintinstructions页面状态:Theevalfunction...provideaccesstotheJavaScriptcompiler.Thisissometimesnecessary,butinmostcasesitindicatesthepresenceofextremelybadcoding....那么,document.write如何“提供对JavaScript编译器的访问”呢?谢谢 最佳答案

javascript - 实现 "this page is asking you to confirm that you want to leave"

这是当我想离开某些页面时Firefox发出的警告。根据我在上面看到的页面以及当我在填写表格后尝试关闭页面时出现此警告,我只能假设它在动态页面上工作。哪种技术用于实现此功能?我如何在一个简单的hello-world页面上自己实现它? 最佳答案 您基本上为beforeunload事件实现了一个处理程序。这使您可以警告用户他们有未保存的数据。伪代码:window.onbeforeunload=functionwarnUsers(){if(needToConfirm){//checktoseeifanychangestothedataent

javascript - InvalidStateError : An attempt was made to use an object that is not, 或不再可用

以下适用于Chrome但不适用于Firefox:varmyVideo=document.getElementById('myVideo')myVideo.currentTime=570在Firefox中它说InvalidStateError:Anattemptwasmadetouseanobjectthatisnot,orisnolonger,usable第2行。 最佳答案 当对象(在本例中为视频)加载不足,无法设置currentTime并向前跳时,就会发生该错误。您必须等到视频可以播放后才能设置currentTimevarmyVi

javascript - 使用 document.write 异步加载 javascript

我正在尝试异步googlemapapijavascript。所以,正常的脚本标签有效但是,下面的异步版本没有。(function(){vargmap=document.createElement('script');gmap.type='text/javascript';gmap.async=true;gmap.src='https://maps.googleapis.com/maps/api/js?sensor=false';vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(gmap,s

javascript - 什么时候应该使用 .innerHTML 以及什么时候在 JavaScript 中使用 document.write

是否有一般规则,何时应使用document.write更改网站内容,何时应使用.innerHTML?到目前为止,我的规则是:1)添加新内容时使用document.write2)更改现有内容时使用.innerHTML但我很困惑,因为有人告诉我,一方面.innerHTML是一个奇怪的Microsoft标准,但另一方面我读到了document.write在XHTML中是不允许的。我应该使用哪些结构来使用JavaScript操作我的源代码? 最佳答案 innerHTML可用于通过字符串修改来更改DOM的内容。因此,如果您想在所选元素的末尾添

javascript - "An IndexedDB transaction that was not yet complete has been aborted due to page navigation"

我正在使用IndexedDB来存储一些数据。它似乎有效,但如果我刷新页面,我会在Firefox(36.0.4)的浏览器控制台中看到:尚未完成的IndexedDB事务已因页面导航而中止。。我正在使用这个(本地)文件进行测试:varrequest=window.indexedDB.open("test_db",2);request.onupgradeneeded=function(event){request.result.createObjectStore("test_store");};request.onsuccess=function(event){vardb=request.re