"警告:在DOM Core 1,2和3中,Attr继承自Node.在DOM4中不再是这种情况.为了使Attr的实现达到规范,正在进行将其更改为不再继承Node的工作你不应该在Attr对象上使用任何Node属性或方法.从Gecko 7.0(Firefox 7.0/Thunderbird 7.0/SeaMonkey 2.4)开始,那些要删除的属性或方法会向控制台输出警告信息.你应该修改你的代码相应地.请参阅弃用的属性和方法以获取完整列表."
向下滚动页面,我们可以使用Attr.name和Attr.value查看nodeName和NodeValue的替换.
https://developer.mozilla.org/en/DOM/Attr#Deprecated_properties_and_methods
它对于属性或childNodes等其他方法意味着什么?该参考文献称它已被弃用,但它们没有给予任何替代!
它已被弃用于属性,但它也适用于Node吗?
Attr对象:http://www.w3schools.com/jsref/dom_obj_attr.asp
编辑:对于Attributes(Attr),只能弃用nodeValue,因为Attr将不再在DOM Level 4中从Node继承:
这是一个帮助我理解的简单示例:
<div id="myAttribute">myTextNode</div>
var myDiv = document.getElementById("myAttribute");
// If you want to get "myAttribute" from div tag
alert(myDiv.attributes[0].value);
// Correct way to get value of an attribute (displays "myAttribute")
alert(myDiv.attributes[0].nodeValue);
// Working too but deprecated method for Attr since it doesn't inherit from Node in DOM4 (.nodeValue is specific to a Node, not an Attribute)
// If you want to get "myTextNode" …
Run Code Online (Sandbox Code Playgroud) 我正在使用(已弃用的)Twitter API 1.0 进行一些测试
例如,我想从 API 获取数据,客户端使用来自任何跨源网页的 AJAX 浏览器请求。它可以是新的空白标签、本地 HTML 页面或任何现有网站。
我试过 JSONP,它工作得很好,但我想使用默认的 XMLHttpRequest 即使 Twitter 服务器不支持 CORS http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing。
例如,在 google.com 主页上,我创建了一个对 Twitter API 的简单 AJAX 调用,并使用 Firebug 执行:
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.twitter.com/1/friends/ids.json?screen_name=baptx", false);
xhr.send();
Run Code Online (Sandbox Code Playgroud)
由于同源策略,这将不起作用并在 Firebug 上打印错误:
Error: Failure
xhr.send();
Run Code Online (Sandbox Code Playgroud)
它返回一个 HTTP 200 OK 代码,但没有从服务器收到 JSON 数据。
我已经看到来自 google.com 网页的请求和来自 api.twitter 网页的请求之间的两个差异(它适用于 Twitter API 请求,因为它是 API 域名,同源)。
添加了一个带有当前域名的 Origin HTTP 标头:
Origin https://www.google.com
Run Code Online (Sandbox Code Playgroud)
Referer HTTP 标头不是 https://api.twitter.com/像来自 api.twitter.com 页面的请求,但在我的情况下是:
Referer https://www.google.com/webhp?hl=en
Run Code Online (Sandbox Code Playgroud)
这就是为什么我尝试删除 Origin HTTP …
有些事情我不清楚:
var myDiv = document.getElementById("myDiv");
var computedStyle = window.getComputedStyle(myDiv);
Run Code Online (Sandbox Code Playgroud)
1)如果只有一种颜色,则不可能直接获得div的全局边框颜色,每边都相同:
computedStyle.getPropertyValue("border-color");
Run Code Online (Sandbox Code Playgroud)
而不是做:
computedStyle.getPropertyValue("border-left-color");
Run Code Online (Sandbox Code Playgroud)
要么
computedStyle.getPropertyValue("border-right-color");
Run Code Online (Sandbox Code Playgroud)
要么
computedStyle.getPropertyValue("border-top-color");
Run Code Online (Sandbox Code Playgroud)
...
2)当在CSS文件中具有样式属性时,它们只能通过getComputedStyle方法访问,而不能通过样式属性(如内联定义的样式属性)访问,通过div中的样式属性,我是对的吗?
myDiv.style.getPropertyValue("border-left-color");
Run Code Online (Sandbox Code Playgroud)
这不行.
3)如果我们要设置样式属性,我们必须使用元素的style属性,是不是可以使用计算出的样式对象?
computedStyle.setProperty("border-color", "yellowgreen", null);
Run Code Online (Sandbox Code Playgroud)
我认为使用style属性是"旧方法",比如使用内联样式属性或使用object.style.property ="value"在Javascript中设置样式属性.
谢谢.
jsFiddle:http://jsfiddle.net/pgtFR/12/
这个问题是这样的:在openSUSE中工作的套接字在Debian中不起作用?
在我的Debian系统上使用套接字时,我必须使用nc -l -p port_number来模拟我想要与之交谈的服务器.如果我使用的是nc -l port_number,则在使用套接字连接功能时会失败,而strerror(errno)会说"Connection refused".
没有-p选项的Netcat在其他Linux发行版上运行良好,我应该如何更改配置?
我有一个HTML5画布图像,我绘制了一些点,我想在点旁边对齐一些div标签和文本输入标签.
不幸的是,浏览器不同意每个div和输入标签之间的空间.
通过使用CSS指定高度,我发现了输入标记的黑客攻击.现在输入标签在每个浏览器之间具有相同的空间.根据浏览器的不同,输入标签的默认高度似乎不一样,非常非常奇怪.
我为我的div标签尝试了同样的事情,但我无法为每个浏览器获得正确的对齐方式.
文本输入标签对齐与每个浏览器一起使用CSS hack:http: //jsfiddle.net/baptx/XcKZj/
div标签对齐方式不同,具体取决于浏览器(为Firefox配置):http: //jsfiddle.net/baptx/92gPY/
我在Linux上使用Firefox,我注意到Windows版本没有渲染相同的边距.在Linux或Windows上运行时,Chrome也不同意Linux Firefox.Opera很棒,它总是与在Linux或Windows上运行的Linux Firefox一致.
我首先想到的是,这是由于网页浏览器引擎,Gecko渲染与Webkit相比有所不同,但如果Windows和Linux版本的Firefox不同意,那应该是别的了.
有没有人和想法来自哪里以及如何使用div标签解决这个问题?
I would like to execute functions one at a time and call another function when a function is finished. I was able to do it using callbacks but not using a promise chain. Here is what I tried (based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#chained_promises) but it executes the first 3 functions at the same time instead of waiting 1 second in each function:
function displayAll() {
var myPromise = (new Promise(display1))
.then((new Promise(display2))
.then((new Promise(display3))
.then(display4)));
}
function display1(resolve) {
setTimeout(function () …
Run Code Online (Sandbox Code Playgroud) HTML 代码:
<input id="txtSizeBeforeValue" type="text" size="5" value="blabla">
<input id="txtValueBeforeSize" type="text" value="blabla" size="5">
Run Code Online (Sandbox Code Playgroud)
HTML解析代码:
<input id="txtSizeBeforeValue" type="text" value="blabla" size="5">
<input id="txtValueBeforeSize" type="text" size="5" value="blabla">
Run Code Online (Sandbox Code Playgroud)
在这里你可以看到 Firefox HTML 解析器有一个问题,每个 HTML 标签的标签属性都被严重重新排序,比如输入文本/按钮、文本区域、画布......即使你像重新排序一样编写标签属性,它也会再次重新排序。该问题在 Firebug 和 Firefox 的 HTML 分析开发工具中可见,因此它不可能是 Firebug 问题。Google Chrome 没有问题,因为 HTML 解析器不会重新排序标签属性。
您的 Firefox 也有这个问题吗?每个平台都有吗?
html ×4
javascript ×4
css ×2
dom ×2
ajax ×1
cors ×1
cross-domain ×1
css-reset ×1
debian ×1
deprecated ×1
dom4 ×1
firebug ×1
firefox ×1
http-headers ×1
netcat ×1
parsing ×1
promise ×1
settimeout ×1
sockets ×1
unix ×1