草庐IT

windows-controls

全部标签

javascript - 为什么IE11在使用window.onbeforeunload时会报错?

我已将我的问题分解为以下简单代码:IEtest$(document).ready(function(){$('.js-click').click(function(e){window.location.href='http://www.google.com/';});window.onbeforeunload=function(e){return'movingon';};});Google这在chrome中按预期工作,没有警告或错误,但在IE11中,当您选择“停留在此页面”时,它会抛出以下错误:File:10.0.1.126:8080,Line:10,Column:11知道为什么吗?

javascript - Controller 的未知提供程序错误

这是我的app.js文件的样子://IonicStarterApp//angular.moduleisaglobalplaceforcreating,registeringandretrievingAngularmodules//'starter'isthenameofthisangularmoduleexample(alsosetinaattributeinindex.html)//the2ndparameterisanarrayof'requires'//'starter.controllers'isfoundincontrollers.jsangular.module('star

javascript - 在 Controller 中使用它而不是 $scope

我正在尝试遵循Angular的风格指南,那里写道我们应该使用thisinstedscope...Styleguide当我能够使用this时,有人可以解释一下吗?这是我的尝试......我做错了什么?我正在尝试切换表单....这是我的html代码:REPLYCLOSE使用经典的$scope我会在我的Controller中这样做:$scope.formEdit=function(data){data.formEditShow=!data.formEditShow;}但是使用this它应该看起来像这样(但不起作用):varvm=this;vm.formEdit=formEdit;functi

javascript - 服务器 : how to get "window", "location"和其他 "window"属性以及通常是浏览器对象上的浏览器代码?

我想在浏览器和服务器上都使用浏览器代码。我的代码基本上是React组件。我想浏览代码,得到一个编译表app.js并在浏览器和服务器上同时使用它://inabrowser//onaservervarApp=require('../assets/js/react/app');但据我所知,browserify不知道window对象。我不能在服务器端要求浏览器代码,抛出一个错误:if(window.location.pathname=='/foo'){^ReferenceError:windowisnotdefined代码如下:...manyReactcomponentsgohere...//

javascript - jquery 中 window.resize() 和 window.on ('resize' ) 之间的区别

window.resize()和window.on('resize',function())有什么区别在jquery中? 最佳答案 来自jQuery页面.resize():Thismethodisashortcutfor.on('resize',handler).和.on()是:The.on()methodattacheseventhandlerstothecurrentlyselectedsetofelementsinthejQueryobject.AsofjQuery1.7,the.on()methodprovidesallfu

javascript - JavaScript 中的 window.window

为什么浏览器中的window对象指向window对象。Mozilla网站将原因声明为Thepointofhavingthewindowpropertyrefertotheobjectitselfwas(probably)tomakeiteasytorefertotheglobalobject(otherwiseyou'dhavetodoamanualvarwindow=this;assignmentatthetopofyourscript).所以,我的问题是,如何无限地将对象指向对象,以及这如何有助于避免执行varwindow=this;window.window//returnswi

javascript - 使用 Angular1+ ES6 时, Controller 函数中的依赖注入(inject)未定义, Controller 作为类

我正在使用ES6类来定义我的Controller,所以这是语法,exportclassSearchBarController{constructor($log){'ngInject';$log.debug("Hello");}textTyped($log){$log.debug("changefired.");}}查看:因此,构造函数中的“Hello”已被正常记录。但是,typedText()函数中的“changefired”并未触发,因为显然未定义如何让我的类函数textTyped()访问$log服务?注意:如果我在构造函数中将$log分配给类属性,例如,this.logger=$l

javascript - 单击时如何从 Controller 获取数据到指令

当我使用ng-clicked时,我试图从Controller将数据发送到指令链接函数,但是我未能将数据发送到指令,该指令在页面加载时调用第一次这是我的html代码click这是我的Controller.controller('myController',function($scope){$scope.clickMe=function(somedata){$scope.myVal=somedata;};});我的指令.directive('myDirective',function(){return{restrict:'E',scope:{myKey:'='},templateUrl:'

javascript - if function with window.location.hash 帮助

我有一个函数可以更改url中的散列并从我的主页插入/删除一个div。我这样做是为了让我可以拥有一个页面,您可以在不重新加载的情况下进行操作,但与此同时,我希望人们能够为某个部分添加书签并稍后转到它而无需再次浏览该页面。当我尝试调用我的hash()函数时,该函数关闭所有div并根据哈希打开特定的div,但它不起作用。我可能在if语句中没有正确的东西,因为当我在hash()函数中放置一个alert()时,它弹出像它应该的那样。functionhash(){if(window.location.hash=="dcontact"){removedivs();InsertContent('dco

javascript - Firefox 中的 window.location.hash 问题

考虑以下代码:hashString=window.location.hash.substring(1);alert('HashString='+hashString);当使用以下哈希运行时:#car=Town%20%26%20Country在Chrome和Safari中的结果将是:car=Town%20%26%20Country但在Firefox(Mac和PC)中将是:car=Town&Country因为我使用相同的代码来解析查询和哈希参数:functionparseParams(paramString){varparams={};vare,a=/\+/g,//Regexforrepl