跳至主要内容

java script 笔记

检查 element type :
设我们有:



type="radio" name="q1" value="1125" />1125
type="radio" name="q1" value="375" />375
type="radio" name="q1" value="178" />178
type="radio" name="q1" value="75" />75
type="radio" name="q1" value="45" />45
type="text" name="q2" value="" />

window.document.forms[0].q1.type=undefined
window.document.forms[0].q1[0].type=radio
window.document.forms[0].q1[1].type=text
window.document.forms[0].q2.type =text
待验证

关于 nodeType
http://javascript.gakaa.com/node-nodetype.aspx 英文
http://fr.selfhtml.org/javascript/objets/node.htm#node_type 法文

Object Oriented Programming in JavaScript 面向对象
http://mckoss.com/jscript/object.htm

Introduction to Forms 简介
http://www.quirksmode.org/js/forms.html#stext


另:
input 是node名字而不是type,所以可以用getelementByTagName来获得,
问:现在的问题是如何获得特定form下的input,而不是整个document下的。
答:document.forms[0].getElementsByTagName("input"),经测试 可行


问:现在可以找到所有的input tag 和其他类型的tag,比如说checkbox,selection 之类,但是无法找到其相应的attribute,因为很可能那东西根本不在tag里。怎么办?


问:能否通过一个element和并以他的边界为基点,找到离他边界最近的attribute,
答:可以,但是很困难。同样需要先建立attribute list 来进行访问,实际上, 必须先取得所有需要匹配的attribute,然后你用边界为基点一圈一圈扩大来寻找匹配的attribute,但是这个实际上还不如直接建立对,并计算他们的相关度来的划算。
补充:也不尽然,完全可以认为是一个等速螺线以设定的element 边界为包络线,什么时候碰到另外一个element 或者是attribute,那么就计算他们之间的“面积距离”,找到最有可能的attribute,这个比一一对应是不是会强一点?

问:可是这个“碰”怎么定义?
答:即当这个等速螺线的终点落在任意一个attribute或者element的包络线之内。

问:这样是不是需要每时每刻都判断,并且对所有的element, attribute都需要做一个判断器,并且并行?这个太浪费资源了。

另外一个办法:
假设:是否可以把ie的页面认为是一个画布,因为所有的element ,attribute其实都不可能太小(太小用户也会看不见),所以,假设把这个画布用10*10的点阵来表示,每个10*10的小方块认为是一个点,这个点或者属于某个element,或者不属于。如果它同时属于两个以上的element,那就认为他谁也不属于。所以我们可以把整个画布看成是一个100*50的点阵,每个点是一个object,它有一个指针,指向它属于的那个element。ok,现在这个问题变得简单了,我以某个element的那一堆点为中心,扩大它的范围,鉴于所有的element, attribute都是正方形,并且斜对角的对应关系很少见,也没有prio,所以:存在一个m*n的element,其起始点位置为x0,y0, 那么关联区域为:四个:
x0-m,y0 => x0,y0+n,
...
...
...

如上图所示,然后确认是否有点的指针为非空,找到非空的指针所指的element,
此方法的好处是不用建立一个attribute,element的距离表。
问:attribute如何定义?
答:通过研究dom tree的内容发现,所有分离的text都会被认为是分散的node, 这一点在firebug里看得很清楚,chrome自带的工具显示的并不是很好。 所以可以通过遍历所有的texte node来找到所有的attribute list

so : 需要两个list,一个是attribute list, 一个是 element list,然后计算 对之间的距离

prerequisite: 可以设置一些前提条件,基于html tag structure的。
问: 这些先决条件如何设置
答:可以通过研究html 语言来设置.

问:先决条件的list
答:待验证:
1.如果attribute和element有一个共同的parentNode,那么有一定的优先级
2.checkbox和radiobox如果是同名,那么一定是关联的。

评论

  1. 今天倒霉了,和别出租车撞了,我赔钱了。5555555555

    回复删除
  2. 呵呵,真可怜。我还不会开车呢

    回复删除

发表评论

此博客中的热门博文

My childhood

"Each person's life is like a book; some people prefer to savor it slowly, while others like to gradually forget it. Looking back, I want to see if I can discern the trajectory of the world from my seemingly insignificant life. I am a child from the countryside, and perhaps most people cannot understand what my so-called countryside looks like. Indeed, the impressions of the countryside can be very different depending on the country, and moreover, more than 40 years have passed, during these 40 years of rapid development in China. A phrase suddenly comes to mind, 'I see him building tall buildings, I see him feasting, I see everything collapsing.' The place where I was born is a small town in the southwest of China, a town so small that it only has one street, and the widest part is only 3 meters. Paved with stone slabs, worn by many years of use, the slabs are not flat but rather filled with small bumps and hollows, yet strangely smooth. At the end of the street is a ...

youtube script covid

[INTRO - Soft Music Playing] Narrator: "In August 2020, during the COVID-19 pandemic in China, I experienced a series of events that revealed the overbearing, unreasonable, and ignorant aspects of government policies. This story unfolds my observations and experiences in Xinjiang since April, presented in a neutral and factual manner." [Scene Transition - Music Shifts to a More Reflective Tone] Narrator: "April 8th marked the end of my nearly three-month-long home quarantine in Wuhan, as the lockdown was finally lifted. With Xinjiang gradually reopening since March, my work required me to return there as soon as possible." [Visuals: Scenes of Empty Streets in Wuhan, Transitioning to Busy Airports] Narrator: "My journey back to Xinjiang was fraught with delays. The direct flight on China Southern Airlines kept getting postponed. Reluctantly, I had to transit through Xi'an. Before leaving, I reported my health status to the community in Changji City, where I ...

关于 6月16日香港大游行 统计

wikipedia: https://zh.wikipedia.org/wiki/2019年6月16日香港反對逃犯條例修訂草案遊行  主办单位公布游行有200万零1人参与,是香港史上主办方公布最多人参加的游行;而警方宣称游行人数仅有33.8万人[e],警方计算游行人数的方法惹来外媒如路透社[9]、BBC[21]、天下杂志等广泛不信任[22][23]。由于本游行仓促成行,不像6月9日与7月1日的游行有人工智能客观统计,加上这次大游行中人流不断溢出多条原定游行路线以外的街道,令统计人数工作更困难,本游行双方差距甚大的人数统计令到人工智能取代传统点算之议方兴未艾。[5][24]无论如何,此游行的人数是1997年回归以来人数最多则无疑问。众多第三方统计之中,路透社与一众日本传媒仅引用了在现场调试[5]人工智能系统的叶兆辉所提供的估算“50-80万人”. yahoo news: https://yahoo-news.com.hk/BBCChineseNews/4174/ 政府公布的數字往往會比遊行主辦方公布的數字低,偏差有時候會達數倍,一高一低的有關數字常引發爭議。例如,早些時候香港民間人權陣線(簡稱「民陣」)為反對《逃犯條例》修訂舉行數次遊行,對於6月16日舉行的遊行,主辦方「民陣」稱有約200萬人參加,香港警方卻說高峰期只有約33.8萬人。 此文还有历次游行主办方和警方的数据统计比较 Voa: https://www.voachinese.com/a/Hong-Kong-demonstration-numbers-20190709/4992522.html 香港游行人数之差,在近年来日益明显而引人关注。就在这次“两百万”人大游行之前一周,香港人举行了首次“反送中”大游行,游行人数之多,几乎占满了港岛几条主要干线。主办方说超过1百万人上街游行,警方说有24万。双方数字相差四分之三。值得关注的是,每次超大型游行后,总有示威者和警方发生冲突的报道,每次都有人受伤或被捕。 无论如此,从双方数字上来看,2019年6月爆发的两次大游行,(9日和16日),是香港主权移交以来也是香港有史以来最大规模的示威。 上次香港市民举行大规模游行示威,是2003年的反23条大游行。据主办方说那次游行参加人数为50万,警方说只有35万,双方当时的统计数...