我想使用jQuery操纵iframe中的HTML.
我以为我可以通过将jQuery函数的上下文设置为iframe的文档来实现这一点,例如:
$(function(){ //document ready
$('some selector', frames['nameOfMyIframe'].document).doStuff()
});
Run Code Online (Sandbox Code Playgroud)
然而,这似乎不起作用.一些检查显示我的变量frames['nameOfMyIframe']是undefined除非我等待一段时间加载iframe.但是,当iframe加载时,变量不可访问(我得到permission denied-type错误).
有没有人知道这方面的解决方法?
当一个html元素被"聚焦"(当前被选中/选中)时,许多浏览器(至少是Safari和Chrome)会在它周围放置一个蓝色边框.
对于我正在进行的布局,这会分散注意力并且看起来不正确.
<input type="text" name="user" class="middle" id="user" tabindex="1" />
Run Code Online (Sandbox Code Playgroud)
FireFox似乎没有这样做,或者至少,让我控制它
border: x;
Run Code Online (Sandbox Code Playgroud)
如果有人能告诉我IE的表现如何,我会很好奇.
但让Safari删除这一点点耀斑会很不错.
在检查用户代理是否通过正确的域访问时,哪一项最有效.
如果他们使用某种Web代理访问域名(因为它往往会打破js),我们希望显示一个基于小js的"顶栏"样式警告.
我们考虑使用以下内容:
var r = /.*domain\.com$/;
if (r.test(location.hostname)) {
// showMessage ...
}
Run Code Online (Sandbox Code Playgroud)
这将照顾我们曾经使用的任何子域.
我们应该使用哪个主机名或主机名?
在Firefox 5和Chrome 12中:
console.log(location.host);
console.log(location.hostname);
Run Code Online (Sandbox Code Playgroud)
..两者显示相同.
是因为端口实际上不在地址栏中吗?
W3Schools说主机包含端口.
应该验证location.host/hostname还是我们可以在IE6 +中确定其他所有其他内容?
也许是时候了,也许是我淹没在稀疏的文档中,而且无法绕过Mongoose更新的概念:)
这是交易:
我有一个联系方案和模型(缩短属性):
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var mongooseTypes = require("mongoose-types"),
useTimestamps = mongooseTypes.useTimestamps;
var ContactSchema = new Schema({
phone: {
type: String,
index: {
unique: true,
dropDups: true
}
},
status: {
type: String,
lowercase: true,
trim: true,
default: 'on'
}
});
ContactSchema.plugin(useTimestamps);
var Contact = mongoose.model('Contact', ContactSchema);
Run Code Online (Sandbox Code Playgroud)
我收到客户的请求,其中包含我需要的字段,因此使用我的模型:
mongoose.connect(connectionString);
var contact = new Contact({
phone: request.phone,
status: request.status
});
Run Code Online (Sandbox Code Playgroud)
现在我们解决了这个问题:
contact.save(function(err){...})如果有相同电话号码的联系人已经存在,我将收到错误(正如预期的那样 - 唯一)update()给联系人,因为文件上不存在该方法Contact.update({phone:request.phone}, contact, {upsert: true}, function(err{...})如何恢复从我的MySQL数据库的一个.myd,.myi,.frm文件?
在HTML标题中,我有这个:
<head>
<title>Title</title>
<link href="styles.css" rel="stylesheet" type="text/css"/>
<link href="master.css" rel="stylesheet" type="text/css"/>
Run Code Online (Sandbox Code Playgroud)
styles.css是我的页面特定表.master.css是我在每个项目中使用的工作表来覆盖浏览器默认值.哪些样式表优先考虑?示例:第一张包含特定的
body { margin:10px; }
Run Code Online (Sandbox Code Playgroud)
和相关的边界,但第二个包含我的重置
html, body:not(input="button") {
margin: 0px;
padding: 0px;
border: 0px;
}
Run Code Online (Sandbox Code Playgroud)
从本质上讲,CSS的级联元素在样式表引用方面是否与在典型的CSS函数中一样?这意味着最后一行是显示的那一行?
这是我需要的一些JS代码:
var secDiff = Math.abs(Math.round((utc_date-this.premiere_date)/1000));
this.years = this.calculateUnit(secDiff,(86400*365));
this.days = this.calculateUnit(secDiff-(this.years*(86400*365)),86400);
this.hours = this.calculateUnit((secDiff-(this.years*(86400*365))-(this.days*86400)),3600);
this.minutes = this.calculateUnit((secDiff-(this.years*(86400*365))-(this.days*86400)-(this.hours*3600)),60);
this.seconds = this.calculateUnit((secDiff-(this.years*(86400*365))-(this.days*86400)-(this.hours*3600)-(this.minutes*60)),1);
Run Code Online (Sandbox Code Playgroud)
我想在之前获得日期时间,但是如果正在使用DST,则日期将关闭1小时.我不知道如何检查DST是否正在使用中.
我如何知道夏令时的开始和结束时间?
我正在使用JSLint来验证我的大多数外部Javascript文件,但我得到的最大错误来自于在定义之前使用的函数.
这真的是我应该担心的问题吗?
看来Firefox,IE7和Chrome都不在乎.像JSLint 一样,流行的init()(通常我经常使用的)函数通常会粘在顶部,因为这对我来说main()是合理的(我喜欢假装它类似)将需要被推到文件的底部.
JavaScript有parseInt()和parseFloat(),但没有parseBool或parseBoolean方法在全球范围内,据我所知.
我需要一个方法,使用"true"或"false"之类的值来获取字符串并返回JavaScript Boolean.
这是我的实现:
function parseBool(value) {
return (typeof value === "undefined") ?
false :
// trim using jQuery.trim()'s source
value.replace(/^\s+|\s+$/g, "").toLowerCase() === "true";
}
Run Code Online (Sandbox Code Playgroud)
这是一个很好的功能吗?请给我你的反馈.
谢谢!