草庐IT

Manipulating_the_browser_history

全部标签

javascript - 对象内的 XMLHttpRequest : how to keep the reference to "this"

我从javascript对象内部进行一些Ajax调用。:myObject.prototye={ajax:function(){this.foo=1;varreq=newXMLHttpRequest();req.open('GET',url,true);req.onreadystatechange=function(aEvt){if(req.readyState==4){if(req.status==200){alert(this.foo);//referencetothisislost}}}};在onreadystatechange函数中,this不再引用主对象,所以我无权访问this

javascript - "Assertion failed: you need to wait for the runtime to be ready"在JavaScript中调用C函数时出错

我正在尝试一个简单的示例来调用使用JavaScript编译为.wasm的C函数。这是counter.c文件:#includeintcounter=100;EMSCRIPTEN_KEEPALIVEintcount(){counter+=1;returncounter;}我使用emcccounter.c-sWASM=1-ocounter.js编译了它。我的main.jsJavaScript文件:constcount=Module.cwrap('count','number');console.log(count());我的index.html文件只加载正文中的两个.js文件,没有别的:我得

javascript - history.go(-1) 返回在 Chrome 中不起作用

href="#"onclick="closeOrCancel()和history.go(-1)中的js方法在Chrome中不起作用(history.back())它适用于href="javascript:closeOrCancel()",但Opera不允许href="javascript:...如何使用onclick="myFunction()"让历史返回?编辑:closeOrCancel()返回false 最佳答案 在onclick代码中添加一个returnfalse;似乎就足够了:GoBack

javascript - history.pushstate 不更新标题

我正在使用AJAX加载页面的主要内容。使用history.pushstate(Object:State,String:Title,String:URL)-我能够更新地址栏中的URL并返回历史记录。但是title参数似乎没有效果。窗口标题和“历史列表”中条目的标题都没有改变(也许两者都是一样的)。我做错了什么?更新:title参数在chrome中被忽略。http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-June/026827.html 最佳答案 title参数不是窗口标题

javascript - 从没有页眉和页脚的 javascript 打印 : state of the art?

当我使用javascript打印内容时,浏览器会自动添加页眉和页脚(url/date/pagenr)。目前似乎没有办法从webapp端抑制这一点。Css3最终可能会成为它的解决方案(例如使用@page,@top-leftstyles),但目前似乎在这里不起作用(winvistachrome17.0.942.0/firefox9.0).它应该什么时候出现在浏览器中?chrome-browser可能会出现另一种解决方案:在以上版本中,printdlg不是模态system-printdlg,而是在网站内呈现(还有一个禁用页眉和页脚的复选框)。既然chrome重做了printdlg,chrom

javascript - 查询选择器全部 : manipulating nodes

据我所知,querySelector返回一个真正的可变元素,而querySelectorAll返回一个非实时静态节点集。我想调整适合特定选择器的所有元素的样式。它适用于querySelector的第一个元素,但不适用于所有querySelectorAll的匹配元素。我想那是因为节点集是非事件的。有解决办法吗?还是我遗漏了什么? 最佳答案 问题是querySelector返回单个节点。querySelectorAll返回一组节点(active意味着如果您更新它们,集合中的元素不会被删除)。您需要为每个匹配的元素设置一个样式,可能需要一

javascript - knockout validation : how to validate the fields on button click, 不在输入更改时

我正在使用以下knockoutvalidation插件:https://github.com/Knockout-Contrib/Knockout-Validation我想在单击“提交”按钮时验证我的字段,而不是每次更改输入值时。我该怎么做?Javascript:ko.validation.init({insertMessages:false,messagesOnModified:false,decorateElement:true,errorElementClass:'wrong-field'},true);varviewModel={firstName:ko.observable()

javascript - 如何停止警告 : It looks like you're using the development build of the Firebase JS SDK?

Itlookslikeyou'reusingthedevelopmentbuildoftheFirebaseJSSDK.WhendeployingFirebaseappstoproduction,itisadvisabletoonlyimporttheindividualSDKcomponentsyouintendtouse.FortheCDNbuilds,theseareavailableinthefollowingmanner(replacewiththenameofacomponent-i.e.auth,database,etc):https://www.gstatic.com/

javascript - 在HAML中,如何在:javascript region so that comments do not show to the public?中写注释

在HAML中,我们可以使用-#somecommentanditwon'tbecomeHTMLandmadepublic但如果它在里面:javascript-#commentslikethislinewillbreakthejavascriptinterpreterasitbecomesjavascriptcode//soweareforcedtousecommentlikethisandispubliclyviewable有没有办法让它不公开? 最佳答案 #{}-block被评估,所以你可以写#{#thisisarubycommen

javascript - react + 终极版 : "<Provider> does not support changing ` store` on the fly"

我收到这个错误:doesnotsupportchangingstoreonthefly.ItismostlikelythatyouseethiserrorbecauseyouupdatedtoRedux2.xandReactRedux2.xwhichnolongerhotreloadreducersautomatically.Seehttps://github.com/reactjs/react-redux/releases/tag/v2.0.0forthemigrationinstructions.我有一个组件:importReact,{Component}from'react';i