草庐IT

simulating-locations-with-xcode

全部标签

javascript - 此警告消息是什么意思? 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images'

为什么我会收到此警告?warning:imgelementsmusthaveanaltprop,eitherwithmeaningfultext,oranemptystringfordecorativeimagesjsx-a11y/img-has-alt它显示第13行,但没有使用任何Prop。 最佳答案 这意味着当您在HTML中创建图像时,为了屏幕阅读器和文本浏览器的利益,您应该包含一个alt属性。 关于javascript-此警告消息是什么意思?'imgelementsmusthave

javascript - Angular 错误 : [filter:notarray] Expected array but received: {} with a filter on an ng-repeat

我正在尝试使用ng-repeat指令使用对API的Angular请求来填充html表。首先加载html页面,然后请求获取返回响应时填充表格的数据。当我向ng-repeat指令添加过滤器时,表格被填充并且过滤器起作用,但是在我的chrome浏览器控制台中,我收到以下错误:Error:[filter:notarray]Expectedarraybutreceived:{}http://errors.angularjs.org/1.4.3/filter/notarray?p0=%7B%7DatREGEX_STRING_REGEXP(angular.js:68)atangular.js:182

javascript - setTimeout 和 window.location (location.href) 不工作

我想在5秒内将用户重定向到index.php,但它立即重定向了我。我不想在这个简单的代码中使用jQuery。setTimeout(function(){location.href="index.php",5000}); 最佳答案 这是正确的方法...setTimeout(function(){location.href="index.php"},5000);你可以在这里查看文档:https://developer.mozilla.org/en/docs/DOM/window.setTimeout语法:vartimeoutID=win

javascript - window.location.replace() 无法重定向浏览器

我使用页面进行导航,但这段代码不起作用,这是什么问题?$(document).ready(function(){$("body").keydown(function(event){if(event.keyCode==37){//leftwindow.location.replace("http://newsii.abudayah.com/photo/2)";}elseif(event.keyCode==39){//rightwindow.location.replace("http://newsii.abudayah.com/photo/31)";}});});

javascript - location.reload(true) 已弃用

我知道重新加载Angular单页应用程序并不理想。但是有一个地方我需要重新加载完整的应用程序。TSLint表示不推荐重新加载。有什么替代方案吗? 最佳答案 您可以在没有forceReload标志的情况下使用location.reload()。这只是被弃用,因为它不在规范中:https://www.w3.org/TR/html50/browsers.html#dom-location-reload 关于javascript-location.reload(true)已弃用,我们在Stack

JavaScript 面向对象 : method definition with or without "prototype"

是这段代码吗,functionPerson(){functionmyMethod(){alert('hello');}this.method=myMethod;}相当于:functionPerson(){}Person.prototype.method2=function(){alert('hello');};如果是,我应该使用哪个方法定义,为什么? 最佳答案 在您的简单示例中,它们在功能上是等效的,但在幕后的工作方式却大不相同。函数的prototype属性实际上是“原型(prototype)模板”。它说“每当创建一个对象并且我被用

javascript - grunt-contrib-watch with LiveReload 不工作

我无法让LiveReload与Grunt一起工作。我正在使用grunt-contrib-watch。当Grunt查看指定的文件时,浏览器中没有重新加载任何内容。所以我会看到:Running"watch"taskCompletedin0.203satThuNov21201300:59:59GMT-0500(EST)-Waiting...OK>>File"views/index.html"changed.但是浏览器窗口没有更新。我正在使用LiveReload2.0.9。关于如何让它运行有什么建议吗?Gruntfile.jsmodule.exports=function(grunt){'us

javascript - 不验证直接使用window.location.href是否安全

在没有任何验证的情况下使用window.location.href是否安全?例如:varvalue=window.location.href;alert(value);从上面的例子来看,它是否容易受到跨站脚本(XSS)攻击?如果是,那又如何呢?攻击者如何将window.location.href的值修改为恶意内容?编辑(第二种情况)这是网址:www.example.com?url=www.attack.com假设我有一个getQueryString()函数,它会在未经验证的情况下返回值。varvalue=getQueryString('url');window.location.hre

javascript - jQuery 解析 XML : get an element with a specific attribute

我正在开发一个HTML5应用程序。我想像这样解析XML:......我想获取具有属性lang="en"的名称和描述。我开始写代码,但我不知道如何完成:functionloadCards(lang){$.ajax({type:"GET",url:'data/english.xml',dataType:"xml",success:parseCardsXml});}functionparseCardsXml(xml){$(xml).find('Card').each(function(){varid=$(this).attr('id');varname=$(this).find('name'

javascript - 使用 get set "exited with code 1"编译 TypeScript 错误代码

gettopLeft(){returnthis._topLeft;}settopLeft(value){this._topLeft=value;Recalc();}上面的代码可以在TypeScriptPlay中找到,但我收到构建错误从VisualStudio2012编译它时错误“退出代码1”有没有人尝试在TypeScript中获取、设置并成功构建? 最佳答案 您需要以ECMAScriptv5为目标,即将-targetES5参数传递给编译器。这需要在项目文件目标配置中设置。我不知道VS是否有任何内置的机制来编辑目标配置,所以我只能告诉