草庐IT

CREATE_NO_WINDOW

全部标签

javascript - window.history.length 最大值

window.history.length的值在我们的项目中非常重要,可以检测浏览器上的后退按钮是否被点击。但是我意识到window.history.length没有超过50。如何解决这个问题?感谢您的帮助。 最佳答案 根据您是否需要它在session间保持持久并在清除用户信息(缓存、localStorage等)后继续存在,您可能需要采用不同的解决方案。其中一个解决方案可能是做这样的事情:window.onpopstate=function(event){varcount=parseInt(localStorage.getItem(

javascript - 为什么在扩展对象时使用 Object.create 作为原型(prototype)?

我有Java背景,最近一直在尝试JavaScript继承。我开始编写一些对象,在阅读了一些示例后,我找到了最适合我的代码风格。这是我的:varClass=function(){};Class.extend=function(p_constructor){varSuperclass=this;//thefollowinglineconfusesmep_constructor.prototype=Object.create(Superclass.prototype);p_constructor.prototype.constructor=p_constructor;p_constructo

javascript - window.parent 不是未定义的?

我有一个页面。没有iframe:而且我需要检查页面是否在Iframe中,所以我这样做了:if(!window.parent){...不在iframe中...}但似乎window.parent永远不会undefined并且总是引用窗口(self===parent)。这是为什么呢?窗口没有(!)父窗口。那么为什么要定义它呢?注意我知道window.window.w....是相同的,这是有原因的。但我在谈论parent(!)我知道我可以检查这个条件:if(window.self===window.parent)...但我的问题仍然存在。 最佳答案

javascript - Protractor E2E测试错误: Object [object Object] has no method 'getWindowHandle'

我正在尝试检查点击按钮打开facebook登录的弹出窗口。Error:Object[objectObject]hasnomethod'getWindowHandle'.代码片段生成错误:describe('Tests',function(){varptor;varhandlePromise;varutil=require('util');beforeEach(function(){ptor=protractor.getInstance();handlePromise=ptor.getAllWindowHandles();varhandlesDone=false;ptor.get('/S

javascript - $window.print(),在angular js中不打印更新后的模型数据

我有一个包含一些数据的表格,可以在html中查看。当我点击打印时,我需要从数据库中获取所有数据并打印出来。当我点击打印时,我正在获取数据并填充模型数据,只有模型被更新,打印显示旧数据。在下面的代码中,当我单击打印时,新项目不会添加到项目中。http://jsfiddle.net/vijaivp/Y3BJa/306/HTMLOverallReportNamePriceQuantity{{item.Name}}{{item.Price}}{{item.Quantity}}JSfunctionPrintCtrl($scope,$window,$q){$scope.items=[{Name:"

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 - 服务器 : 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 - 添加提供程序@NgModule 时出现 Angular2 "No provider for Service!"错误

我有一个应用程序模块和单组件应用程序(用于演示我的问题),并出现以下错误:Errorin./AppComponentclassAppComponent_Host-inlinetemplate:0:0causedby:NoproviderforUserService!;Zone:;Task:Promise.then;Value:AppModule代码:import{NgModule}from'@angular/core';import{BrowserModule}from'@angular/platform-browser';import{UserService}from'./compo