我正在尝试使用带弹出页面的浏览器操作访问Chrome中的浏览器历史记录.
var histories = [];
var visits = [];
chrome.history.search({'text':'', 'maxResults':0}, function(historyItems){
for(var h in historyItems){
histories.push({'id': h.id, 'url':h.url});
}
});
for(var h in histories){
chrome.history.getVisits({'url': h.url, function(visitItems){
for(var v in visitItems){
var id = v.id;
var visitId = v.visitId;
var visitTime = v.visitTime;
var referringVisitId = v.referringVisitId;
var transition = v.transition;
visits.push({'id': v.id, 'visitId': v.visitId, 'visitTime': v.visitTime, 'referringVisitId': v.referringVisitId, 'transition':v.transition});
}
});
}
console.log(histories.length + ' histories');
console.log(visits.length + ' visits');
Run Code Online (Sandbox Code Playgroud)
结果我得到234个历史记录和0次访问.我怎么能有一堆没有访问的页面?我究竟做错了什么?
我正在学习backbone.js并且在本教程后面有问题.我有一个Era
名为的集合History
.在尝试时,app.History.create({ from: 0, until: 1, stash: {from: null, until: null}, _enabled: true})
我在标题中得到错误.
这是我的代码:
该模型
var app = app || {};
app.Era = Backbone.Model.extend({
defaults: {
from: Number.NEGATIVE_INFINITY,
until: Number.POSITIVE_INFINITY,
stash: {
from: null,
until: null
},
_enabled: true
},
toggle: function(){
if(this.get('_enabled')){
this.disable();
}else{
this.enable();
}
this.save();
},
enable: function(){
this.from = this.stash.from;
this.until = this.stash.until;
this.stash.from = null; // strictly speaking unnecssary
this.stash.until = null;
this._enabled = true;
},
disable: function(){ …
Run Code Online (Sandbox Code Playgroud) 我试图提取元素的第n个子元素,以便元素显示堆叠在同一个容器中.
我试过通过https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child阅读,但无济于事.
我在jsfiddle中重新创建了这个问题,
https://jsfiddle.net/ndga732y/
HTML:
<table>
<td>
<p id="image-1">first content</p>
<p id="image-2">second content</p>
</td>
</table>
Run Code Online (Sandbox Code Playgroud)
CSS:
p:nth-child(0n){
offset-x: n*2px;
offset-y: n*2px;
}
Run Code Online (Sandbox Code Playgroud)
我知道使用第n个子选择器选择第n个子项很容易,但是如何使用n值创建不同的偏移量,具体取决于它在容器中的顺序?
提前致谢!
我有一个访问者可以输入数据的表单,我想通过$ _POST变量将这些数据存储在mysql数据库中.我需要什么来阻止SQL注入?
我有两个文件:
# wordlist.rb
code_words = {
'computer' => 'devil worshipping device',
'penny' => 'pretty',
'decoration' => 'girlandes, green light bulbs, skeletons',
'pets' => 'captured souls'
}
Run Code Online (Sandbox Code Playgroud)
和
# confidant.rb
require 'wordlist'
# Get string and swap in code words
print 'Say your piece:
'
idea = gets
code_words.each do |original, translated|
idea.gsub! original, translated
end
# Save the translated idea to a new file
print 'File encoded. Please enter a name for your piece:
'
piece_name = gets.strip
File::open 'piece-' …
Run Code Online (Sandbox Code Playgroud) 我有以下ejs模板
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Emasc Editor</title>
<style>
.list{
display: inline-block;
}
</style>
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javscript">
$(document).ready(function(){
alert('test');
$("#setMembershipsButton").click(function(e){
// send selected person and groups to server and create memberships
data = {
person: $('#person_list').val(),
groups: $('#group_list').val()
};
$.post('/newConnections', data);
});
$("#person_list").change(function(){
alert('test');
// send selected person to server and retrieve memberships
$.post('/getPersonGroups', { personID: $('#person_list').val() }, function(data, textStatus){
$('#group_list option').removeAttr('selected');
for(var i=0; i<data.ids.length; i++){
$('#group_list option[value=' + data.ids[i] + ']').attr('selected', 'selected');
}
});
});
}); …
Run Code Online (Sandbox Code Playgroud) 我想知道:可以interface
继承另一个班吗?
我试图让一个接口继承自MarshalByRefObject
.
我的意图是实现接口的所有类也从该类继承.
我有一个ASP.NET网站/应用程序,并想知道放置一些应用程序范围设置的好地方.如果可行,我想避免使用我自己的解决方案,并使用已有的解决方案.