{"id":167,"date":"2007-02-17T09:06:45","date_gmt":"2007-02-17T14:06:45","guid":{"rendered":"http:\/\/www.killersites.com\/blog\/2007\/matching-columns-script-update\/"},"modified":"2007-10-01T14:57:27","modified_gmt":"2007-10-01T19:57:27","slug":"matching-columns-script-update","status":"publish","type":"post","link":"https:\/\/www.killersites.com\/blog\/2007\/matching-columns-script-update\/","title":{"rendered":"Matching Columns Script &#8211; Update."},"content":{"rendered":"<p>Hi,<\/p>\n<p>I decided to create another blog post to make it easier to find the updated version of the important <a href=\"https:\/\/www.killersites.com\/blog\/2006\/matching-div-heigths\/\">matching columns script<\/a> &#8211; it was buried in the originals article&#8217;s comments.<\/p>\n<p>Notes:<\/p>\n<ul>\n<li>The original <a href=\"http:\/\/killersites.com\/videoTutorials\/Tutorial_WebDesign2\/matching_divs.html\">matching columns video tutorial<\/a><\/li>\n<li>The original discussion on the <a href=\"http:\/\/www.killersites.com\/mvnforum\/mvnforum\/viewthread?thread=4110#20896\">web design forum<\/a><\/li>\n<\/ul>\n<p> &#8211;<\/p>\n<p>Updated script by: Jonathan del Mar <\/p>\n<p>I have modified the script to work with multiple class groups also with elements with multiple class names<\/p>\n<p>\/*<br \/>\nDerived from a script by Alejandro Gervasio.<br \/>\nModified to work in FireFox by Stefan Mischook for Killersites.com<\/p>\n<p>Modified to work with multiple class groups also with elements with multiple class names<br \/>\nby Jonathan del Mar (dec-14-2006)<\/p>\n<p>How it works: just apply the CSS class of \u00e2\u20ac\u02dccolumn\u00e2\u20ac\u2122 to your pages\u00e2\u20ac\u2122 main columns.<\/p>\n<p>to work with different classes<br \/>\nadd<\/p>\n<p>var columns = new Array(\u00e2\u20ac\u2122class_name1\u00e2\u20ac\u00b2, \u00e2\u20ac\u02dcclass_name1\u00e2\u20ac\u00b2\u00e2\u20ac\u00a6);<\/p>\n<p>by Jonathan del Mar<\/p>\n<p>by default the script will call<br \/>\nmatchColumns();<br \/>\nand the default class_name is \u00e2\u20ac\u02dccolumn\u00e2\u20ac\u2122<br \/>\n(see the bottom of this script)<br \/>\nby Jonathan del Mar<\/p>\n<p>*\/<br \/>\nmatchColumns=function(my_class){<\/p>\n<p>var divs,contDivs,maxHeight,divHeight,d;<\/p>\n<p>\/\/ get all elements in the document<\/p>\n<p>divs=document.getElementsByTagName(\u00e2\u20ac\u2122div\u00e2\u20ac\u2122);<\/p>\n<p>contDivs=[];<\/p>\n<p>\/\/ initialize maximum height value<br \/>\nmaxHeight=0;<br \/>\nif (!my_class) {<br \/>\nmy_class = \u00e2\u20ac\u02dccolumn\u00e2\u20ac\u2122;<br \/>\n}<\/p>\n<p>my_regex = new RegExp(\u00e2\u20ac\u2122(.* |^)\u00e2\u20ac\u2122 + my_class + \u00e2\u20ac\u02dc( .*|$)\u00e2\u20ac\u2122);<\/p>\n<p>\/\/ iterate over all elements in the document<\/p>\n<p>for(var i=0;i elements with class attribute \u00e2\u20ac\u02dccontainer\u00e2\u20ac\u2122<\/p>\n<p>\/\/if(\/\\bcolumn\\b\/.test(divs[i].className)){<br \/>\n\/\/ modified by Jonathan del Mar to match \u00e2\u20ac\u02dccolumn\u00e2\u20ac\u2122 in multiple classes<\/p>\n<p>if(my_regex.test(divs[i].className)){<br \/>\nd=divs[i];<\/p>\n<p>contDivs[contDivs.length]=d;<\/p>\n<p>\/\/ determine height for element<\/p>\n<p>if(d.offsetHeight){<\/p>\n<p>divHeight=d.offsetHeight;<\/p>\n<p>}<\/p>\n<p>else if(d.style.pixelHeight){<\/p>\n<p>divHeight=d.style.pixelHeight;<\/p>\n<p>}<\/p>\n<p>\/\/ calculate maximum height<\/p>\n<p>maxHeight=Math.max(maxHeight,divHeight);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\/\/ assign maximum height value to all of container elements<\/p>\n<p>for(var i=0;i<br \/>\nvar columns = new Array(\u00e2\u20ac\u2122class_name1\u00e2\u20ac\u00b2, \u00e2\u20ac\u02dcclass_name2\u00e2\u20ac\u00b2, \u00e2\u20ac\u00a6);<\/p>\n<p>to your html header. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, I decided to create another blog post to make it easier to find the updated version of the important matching columns script &#8211; it was buried in the originals article&#8217;s comments. Notes: The original matching columns video tutorial The original discussion on the web design forum &#8211; Updated script by: Jonathan del Mar I &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,9],"tags":[20,19],"_links":{"self":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/167"}],"collection":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":0,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}