When using placeholder in text inputs, Safari won’t respect line-height. The text won’t appear to be centered vertically. But if you remove the line-height, it will. Just a heads up.
Archive for the ‘Web Developement’ Category
HTML5 Input Placeholder Safari Bug
Monday, December 5th, 2011JS101 Week 4
Wednesday, March 9th, 2011TRACK 1 – Javascript Videos
Please watch the videos in the links listed below. Some links may contain further notes and links to resources covered in the videos. After watching the videos, reflect on the questions, discuss them on the forums, post your reflections on your blogs. The assignments are for practicing the concepts learned. You can discuss them on the forums, and upload them on your blog or any open source repository where your course peers and facilitators can review and comment on them.
Douglas Crockford: "Theory of the DOM " (1 of 3) @ Yahoo! Video- Article: Traversing the DOM
- Introduction to modifying the DOM
- How to access a form element with Javascript
Questions for reflection (please reflect on your blog and discuss in comments below):
- Q: There were two key innovations to the original (fetch-parse-flow-paint) linear workflow that the Mosaic browser used to render web pages. One allowed for a perception of faster rendering, and the other allowed for us to use AJAX. Explain both?
A: 1) The Mosaic engine had a problem with images, it didn’t know the size of the image. It would reach the parse stage of the workflow have to return fetch stage of the workflow. To fix this, Netscape followed the same workflow, but put a marker in the fetch stage and kept going, and then later, when it got the image, it would paint it in. Essentially, the load didn’t get hung up on an image, it would build around it. Flow and Paint multiple times.
2) Netscape 2 built on this by adding events, which cause a script to get executed. Creating a ‘Flow -> Paint -> Event -> Script’ loop. Something all browsers still use today. - Q: What are the roles of ‘name’ and ‘id’ attributes in HTML tags? What is an appropriate use of both?
A: ‘name’ = Identifies values in form data, Identifies a window/frame. They are mostly used in forms and such
‘id’ = Uniquely identifies an element. This can be used to gain access to an object for use with JS & CSS. - Q: Which pointers does each node in the DOM tree typically have?
A: child, sibling, parent. - Q: Given a node object from a DOM tree, how do we determine if it is a text node or a regular node?
A: If you get a nodes nodeName, a Text node will return #text, a regular node will return something other that #text.Element The tag name, eg. HTML Attr The attribute name, eg. id Text #text CDATASection #cdata-section EntityReference The name of the entity reference, eg. amp Entity The entity name, eg. & ProcessingInstruction The target of the processing instruction, eg. xml-stylesheet Comment #comment Document #document DocumentType The name of the document type, eg. html DocumentFragment #document-fragment Notation The notation name or refer to this check node.nodeType for these:
Node.ELEMENT_NODE == 1
Node.ATTRIBUTE_NODE == 2
Node.TEXT_NODE == 3
Node.CDATA_SECTION_NODE == 4
Node.ENTITY_REFERENCE_NODE == 5
Node.ENTITY_NODE == 6
Node.PROCESSING_INSTRUCTION_NODE == 7
Node.COMMENT_NODE == 8
Node.DOCUMENT_NODE == 9
Node.DOCUMENT_TYPE_NODE == 10
Node.DOCUMENT_FRAGMENT_NODE == 11
Node.NOTATION_NODE == 12
Homework:
- Q: Download the source for the web page ‘http://www.useit.com/about/nographics.html’. In the source page itself, write a Javascript function which counts the number of text nodes in the document and shows the count in an alert dialogue. You can choose how you want to trigger the function (through a button click, link click, or any other event).
A: I had a real hard time putting this one together. I couldn’t think it all the way through the process, I actually poached the code from Melipone Moody. See my version in action here.function walkTheDOM(node, func) { func(node); node = node.firstChild; while (node) { walkTheDOM(node, func); node = node.nextSibling; } } function countTextNodes() { var sum = 0; function count (node) { if (node.nodeType == 3) // TEXT_NODE sum++; } var root = document.documentElement; walkTheDOM(root, count); alert (sum + " text nodes found"); } countTextNodes() - Q: Change the example above so that instead of displaying the count in an alert dialogue, it is displayed in a span tag in the HTML page itself.
A: Simply just built of the previous example and used innerHTML. See it in action here.function walkTheDOM(node, func) { func(node); node = node.firstChild; while (node) { walkTheDOM(node, func); node = node.nextSibling; } } function countTextNodes() { var sum = 0; function count (node) { if (node.nodeType == 3) // TEXT_NODE sum++; } var root = document.documentElement; walkTheDOM(root, count); var add_this_copy = (sum + " text nodes found"); // alert(add_this_copy); document.getElementById('place_content_here').innerHTML = add_this_copy; } countTextNodes() - Q: Add a link besides the button, such that when the link is click, it changes the style on the span tag to make it’s contents bold.
A: Again, building off the previous example… See it here.window.onload=function(){ countTextNodes(); } function walkTheDOM(node, func) { func(node); node = node.firstChild; while (node) { walkTheDOM(node, func); node = node.nextSibling; } } function countTextNodes() { var sum = 0; function count (node) { if (node.nodeType == 3) // TEXT_NODE sum++; } var root = document.documentElement; walkTheDOM(root, count); var add_this_copy = (sum + " text nodes found"); // alert(add_this_copy); document.getElementById('place_content_here').innerHTML = add_this_copy; return add_this_copy; } function change_to_bold(){ var current_text = document.getElementById('place_content_here').innerHTML; var current_text = ''+current_text+''; document.getElementById('place_content_here').innerHTML = current_text; } function change_to_normal(){ var current_text = document.getElementById('place_content_here').lastChild.innerHTML; document.getElementById('place_content_here').innerHTML = current_text; }
#p2pu-Jan2011-javascript101
this site is now HTML5
Tuesday, July 13th, 2010As of today, this site is built using version 5 of Hyper Text Markup Language (HTML5). The bloggery is next! Combining WordPress and HTML5, here we go.
Please update your browser to see the full set of features. The update option is usually under the help option in your browser.
Thanks for keeping your browser technology up to date!
Learning HTML5, as much as I can…
Wednesday, June 2nd, 2010This is a template for HTML5 pages, I think this is the first technological upgrade in mark up language that I will be actively involved with while it transitions.
This layout is very simple, it uses header, section, footer, aside, nav, article, & figure tags as well as the google js and minor CSS styles needed to make it work cross browser. It also has some notes I collected while reading up on said tags. This is the first draft, but I will use it from here on out to get myself going, HTML5 style. I just want a simple, clean starting point to learn from, I felt other sites were making templates that were over complicated. It has no styles, except one, but it’s pretty self explanatory. Hope it helps you too!
Internet Explorer Glitch, new to me.
Thursday, September 24th, 2009I learned about a new annoying issue when using tables and images in IE6 & IE7.
I was working on a email newsletter that is primarily images, except for a small box of body text. I viewed the page in IE7 & IE7 via IE Tester and I was getting a gap under each image that butted against the cell aka td. I tried playing with cellspacing, cellpadding, margin and padding for the cell, links and images. Nothing worked, still had the gap. I did a little research and found out why.
When I code tables and just in general, I like to put the closing tags on their own lines, makes it easier for me to read. Apparently IE6/7 will add a 1px gap after your image if you don’t close the cell/td on the same line as the image. Simple and annoying. Thanks again Microsoft and Internet Explorer.
I tested in these browsers because they are the closest to the good old email apps that treat code like it’s 1999. On a further not, here are some good anti-IE6 websites to check out.