I ran accross a noteworthy question on Experts-Exchange today regarding a javascript error that occurs when you have a cflayout that navigates to a page with a cfchart tag.

The setup is that the main page (home.cfm) has cflayoutareas and one of them has a link that navigates to chart.cfm targeting a specific layout area.

home.cfm:

<cflayout type="border" name="layoutborder">
<cflayoutarea name="Center" position="center">
<a href="#" onclick="ColdFusion.navigate('chart.cfm','Center')">chart</a>
</cflayoutarea>
</cflayout>

chart.cfm:

<cfchart>
<cfchartseries type="line" serieslabel="2008">
<cfchartdata item="January" value="100">
</cfchartseries>
</cfchart>

If you run chart.cfm by itself the chart shows up, but if you rund the main page code you an generic error "Error processing javascript in markup". It seems cfchart doesnt work when linked to via Coldfusion.navigate from a cflayout area.

This error does not pop up in FireFox, but I was able to duplicate it in IE. The solution (revised 6-9-2008) is to add a script tag to define a CF_RunContent() function that uses the DOM to replace the innerHTML of the CFLayoutarea generated DIV layer.

home.cfm:

<html>
<head>
<script type="text/javascript" charset='utf-8'>
function CF_RunContent(src){
setTimeout(function(){document.getElementById('Center').innerHTML = src;},5);
}
</script>
</head>
<body>
<a href="#" onclick="ColdFusion.navigate('chart.cfm','Center');">chart</a>
<cflayout type="border" name="layoutborder">
<cflayoutarea name="Center" position="top" style="width:500px;height:200px" maxSize="200">
test 1
</cflayoutarea>
</cflayout>

</body>
</html>

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Rand's Gravatar Thanks for the tip!
# Posted By Rand | 3/25/08 4:45 PM
Matt's Gravatar This still does not seem to be working correctly. Whenever the chart link is clicked, the chart does load, however the chart is shown on a new page rather than replacing the HTML in the
Center layoutarea. If you change the code on home.cfm to the code below, you can watch both layout areas disappear.

<code>
<script type="text/javascript" charset='utf-8' src='/CFIDE/scripts/CF_RunActiveContent.js'></script>

<a href="#" onclick="ColdFusion.navigate('chart.cfm','Center')">chart</a>
<cflayout type="border" name="layoutborder">
   <cflayoutarea name="Center" position="top" style="width:500px;height:200px" maxSize="200">
      test 1
   </cflayoutarea>
   <cflayoutarea name="Center2" position="center">
      test 2
   </cflayoutarea>
</cflayout>
</code>
# Posted By Matt | 5/30/08 6:50 PM
Scott Bennett's Gravatar @Matt,

Good Catch! I didn't notice that the first time because I was only using one cflayoutarea. I dug a little deeper and it turns out that cf_runactivecontent.js file just sets up a function that uses document.write to write the embed and object tags for the flash file. Unfortunately IE does not allow this to happen after the initial page load so it doesn't work as intended.

Fortunately, where there's a will there's a way =) Here is a workaround/hack for this problem where I used the DOM model instead of the document.write to write the source for the flash object. I also had to put a small delay in there to avoid conflict with the ajax processes. Change the home.cfm to be like this:

<html>
   <head>
   <script type="text/javascript" charset='utf-8'>
   function CF_RunContent(src){
      setTimeout(function(){document.getElementById('Center').innerHTML = src;},5);
      }
   </script>
   </head>
   <body>
   <a href="#" onclick="ColdFusion.navigate('chart.cfm','Center');">chart</a>
   <cflayout type="border" name="layoutborder">
    <cflayoutarea name="Center" position="top" style="width:500px;height:200px" maxSize="200">
    test 1
    </cflayoutarea>
    <cflayoutarea name="Center2" position="center">
    test 2
    </cflayoutarea>
   </cflayout>

   </body>
</html>
# Posted By Scott Bennett | 5/30/08 8:56 PM
Calvin's Gravatar Hello

I have a cfdiv tag that is binded to a page called chart.cfm

for example:
<cfdiv bind="url:chart.cfm?searchClass={what_class}" name="thechart2" ID="thechart2">

the chart.cfm contains the cfchart of which I am trying to display (which is type="flash").

works fine in FF but I am getting the same javascript error that you just talked about in IE 7.

Any thoughts would be greatly appreciated!


Thank you in advance.
# Posted By Calvin | 6/6/08 2:59 PM
Calvin's Gravatar Oh nevermind i got it to work.!!

Thanks!
# Posted By Calvin | 6/6/08 4:10 PM
Gary's Gravatar I am also getting the javascript error, but adding the js call doesn't help.
I am wondering if its because I am using source in my cflayout tag with a bind?
Any suggestions would be hugely appreciated - this is the only place on the net that is talking about this (or so it seems)

<script type="text/javascript" charset='utf-8' src='/CFIDE/scripts/CF_RunActiveContent.js'></script>

<cflayout type="tab" name="mainTab" style="width:900px">
   <cflayoutarea title="Detail" name="tab1" style="padding:10px;" source="#cgi.script_name#?vw=detailChart&product_id={targetProduct_ID:product_id}" />
   <cflayoutarea title="Summary" name="tab2" style="padding:10px;" source="#cgi.script_name#?vw=summaryChart&product_id={targetProduct_ID:product_id}" />
</cflayout>
# Posted By Gary | 6/9/08 5:52 PM
Scott Bennett's Gravatar Gary,

If you look a few comments above, you will see that my original solution (the one in the article) was not really fixing the problem. Even my second solution, which works correctly for 1 cflayoutarea with a chart, will probably not work in your case because you have two cflayoutarea tags with a chart. And, short of modifying some of the js files in the CFIDE directory (which I don't suggest doing), I am not quite sure how I to make it so that the CF_RunContent() could take an extra parameter that when defined will cause the content to be loaded into the defined div layers innerHTML like my workaround does, and using the document.write() when the second parameter is not defined. Ultimately that is probably close to what Adobe will end up doing to resolve this issue.

In the mean time, off the top of my head, it is possible to create a separate AJAX function to pull the carts and then replace the innerHTML of each of the cflayoutarea generated divs with the charts, but I don't have time right at this moment to actually prove that theory with an example. If you (or anyone else) are able to take that suggestion and run with it, please post the solution here if you figure it out. Otherwise, I will do it sometime over the next couple days and post it myself.
# Posted By Scott Bennett | 6/9/08 6:37 PM
Scott Bennett's Gravatar FYI to all readers,

I went ahead and modified this post so that the correct solution is in the actual article, that way people who don't read comments can still get the correct answers.
# Posted By Scott Bennett | 6/9/08 6:46 PM
Crowe182's Gravatar This seems to be on a similar level of an issue I ran across a month ago.

I am using the tab style of cflayoutarea and calling source pages that holds a form. After some time I deduced that in the source page I had a JS function
declared that I was going to be using. I would get "Error processing JavaScript in markup for element cf_layoutarea12404278981088:" everytime I would
select this tab. Once I removed the JS function out to the main cflayout page the issue was gone.

Now what I was wondering was why does this happen? I am running into this issue again but have not yet figured out a "hack" for it. Currently I have a
form in the source page and want to uses JS for a form field focus function. The main function is declared on the main page that houses the cflayout.
However I want to call this function when the source page is loaded thus resulting in the above error.

<script type="text/javascript">
window.onload = formFocus('area');
</script>

Any help would be appreciated.
# Posted By Crowe182 | 4/22/09 5:24 PM
Scott Bennett's Gravatar the window.onload would not run because the window itself is not being reloaded, the source is being retrieved via ajax then a div layer is being dynamically updated with the content. You will have to define a listener on the main layout page so that when that tab is selected, it focuses on the formfield.
# Posted By Scott Bennett | 4/22/09 5:42 PM
Crowe182's Gravatar Ahhh..

Thanks for the help Scott!

My other option was to do a window.setTimeout and just call the function.
# Posted By Crowe182 | 4/22/09 6:06 PM
jerr's Gravatar Thanks for this solution. However, when trying to display two cfcharts in one cfdiv (or two different cfdiv's with one cfchart each),
only the last cfchart is shown.

Any ideas on how I could try to solve this issue?

Basically I'm looking for a way to display two (or maybe more) different cfcharts with a "loading" message on one page (since they load too long for comfort).
# Posted By jerr | 5/18/09 11:22 AM
Eric's Gravatar This is the first instance I've seen with a correct fix (or hack) for the "How to load CFCHART in a CFWINDOW" problem!

I am interested in hacks to the hack itself though, that allow for handling multiple areas.

Please post back if you find the time to come up with a more versatile solution. Haven't seen any of the other CF heavyweights weight in on the issue yet, so you're breaking ground here =)
# Posted By Eric | 6/29/09 12:32 AM
Eric's Gravatar Yay! Found a good fix.


So take the CF_RunContent function you created above and change it so that it looks like this:

CF_RunContent(theDiv,src)

Also replace this line:

setTimeout(function(){document.getElementById('Center').innerHTML = src;},5);

With this ('Center' is replaced):

setTimeout(function(){document.getElementById(theDiv).innerHTML = src;},5);


Now, on the page where you're doing a CFChart or other such tag, wrap it in a CFSAVECONTENT.

After the closing tag for that CFSAVECONTENT, output it like this (or save it to a variable, etc.:

#Replace(YOURCFSAVECONTENTVARIABLE,"CF_RunContent(","CF_RunContent('bottomTD',")#

The "bottomTD" is the ID of the element where you want the graph to go.

Using this you can keep the hack in one spot and just alter the output of graphs and such so that you force it to send in the other variable of where to go :)
# Posted By Eric | 6/29/09 12:44 AM
https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Clapton-PM-Bag-N44243-Magnolia-2361-it.html https://www.bababorses.de/Louis-Vuitton-LV-Trainer-Men-s-Sneakers-Top-Quality-15-5322-it.html https://www.bababorses.de/Celine-Small-Cabas-Bag-In-Black-Leather-it-2087 https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Call-Back-Sandals-Nude-6162-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-MM-Monogram-Vernis-Leather-In-Magenta-4069-it.html https://www.bababorses.de/Louis-Vuitton-Ring-09-557-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-LV-Square-Espadrilles-Slipper-Sandals-Brown-6371-it.html https://www.bababorses.de/Prada-Golden-Saffiano-Calfskin-Leather-Top-Handle-Bag-it-2956 https://www.bababorses.de/Dior-Diorissimo-Small-Bag-Black-Nappa-Leather-Silvery-Hardware-8001-it-22 https://www.bababorses.de/Louis-Vuitton-Idylle-Blossom-Charms-Necklace-Q94360-406-it.html https://www.bababorses.de/Louis-Vuitton-Color-Blossom-BB-Star-Pendant-Necklace-Red-Gold-309-it.html https://www.bababorses.de/Bvlgari-Serpenti-Original-Leather-Framed-Pochette-Sky-Blue-82121-it-1938 https://www.bababorses.de/Louis-Vuitton-Horizon-55-Trolley-Travel-Luggage-Bag-Taiga-Leather-M30331-Red-6892-it.html https://www.bababorses.de/Fendi-By-The-Way-Small-Croc-Satchel-White-it-2731 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-and-PVC-Nano-Bag-M61114-3176-it.html https://www.bababorses.de/Louis-Vuitton-Sarah-Multicartes-Wallet-M61273-Hot-Pink-7624-it.html https://www.bababorses.de/louis-vuitton-speedy-30--Damier-Azur-Canvas-n44367-2300-it.html https://www.bababorses.de/Hermes-Birkin-35cm-cattle-skin-vein-Handbags-blue-golden-it-907 https://www.bababorses.de/Saint-Laurent-Baby-Sac-De-Jour-Bag-In-Rose-Grained-Leather-it-3322 https://www.bababorses.de/Louis-Vuitton-Twist-MM-M53531-M53532-2775-it.html https://www.bababorses.de/Louis-Vuitton-Sunglasses-133-978-it.html https://www.bababorses.de/Louis-Vuitton-Neverfull-MM-M54185-Black-2705-it.html https://www.bababorses.de/Prada-Saffiano-East-West-Medium-Tote-Bag-Nero-it-3042 https://www.bababorses.de/Louis-Vuitton-Compact-Wallet-in-Monogram-Canvas-M63041-7399-it.html https://www.bababorses.de/Prada-Mens-Leather-Pouch-3312-Black-it-3099 https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Lock-It-Flat-Mule-1A7TOX-Pink-5965-it.html https://www.bababorses.de/Fendi-Baguette-Micro-Monster-Bag-Purple-Multi-it-533 https://www.bababorses.de/Louis-Vuitton-LV-Angel-Stud-Earrings-M64293-435-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Zippy-Wallet-Evasion-M61360-7219-it.html https://www.bababorses.de/LOUIS-VUITTON-CATOGRAM-SQUARE-SCARF-MP2266-4818-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Triangle-Shaped-Messenger-Bag-M54330-Black-3865-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Chloe-Marcie-Medium-Satchel-Bag-Cobalt-it-2283 https://www.bababorses.de/louis-vuitton-epi-leather-Soufflot-BB-bag-m55613-black-2580-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55735-4512-it.html https://www.bababorses.de/Louis-Vuitton-Crafty-NeoNoe-MM-bag-black-M45497-2980-it.html https://www.bababorses.de/Louis-Vuitton-Men-Box-Bag-Shoulder-Body-Bag-M44157-Brown-3136-it.html https://www.bababorses.de/Prada-Saffiano-Double-Zip-Executive-Tote-Bag-Gray-it-3025 https://www.bababorses.de/Louis-Vuitton-Epi-Leather-NeoNoe-BB-Bucket-Bag-M53610-Indigo-2564-it.html https://www.bababorses.de/Saint-Laurent-Small-Monogram-Tassel-Satchel-In-Red-Crocodile-Leather-it-3158 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV18-59-it.html https://www.bababorses.de/LOUIS-VUITTON--CLASSIC-MINI-PACKBACK-2872-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Louis-Vuitton-Monogram-Ebene-Canvas-Pegase-Legere-53-Business-Rolling-Luggage-6950-it.html https://www.bababorses.de/Louis-Vuitton-Crocodilien-Brillant-Capucines-Mini-Bag-N93429-Black-2231-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Hoodie-Jacket-Black-1526-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Coated-Canvas-Popincourt-PM-M43462--Raisin-3345-it.html https://www.bababorses.de/Louis-Vuitton-Lockme-Cabas-Tote-M55028-Black-4530-it.html https://www.bababorses.de/Givenchy-Antigona-Small-Leather-Satchel-Bag-Black-it-2432 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Small-Malle-Chain-Bag-3294-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Zippy-Wallet-M62304-Red-7304-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV113-38-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10.5cm-Eyeline-Pumps-Python-Pattern-Suede-Black-5999-it.html https://www.bababorses.de/LOUIS-VUITTON-PEGASE-LEGERE-REGATTA-N41620-MONOGRAM-CANVAS-6974-it.html https://www.bababorses.de/Louis-Vuitton-Kimono-Wallet-M56175-Pink-7437-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Tapestry-Denim-Bidart-Espadrilles-Blue-5726-it.html https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Shirtdress-Blue-1709-it.html https://www.bababorses.de/Louis-Vuitton-Montaigne-MM-M41048-Black-4597-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Crystals-Call-Back-Sandals-Suede-Red-6160-it.html https://www.bababorses.de/Hermes-Bolide-31cm-Togo-Leather-Green-Bag-it-1070 https://www.bababorses.de/Replica-Hermes-Wallet-H001-Wallet-Cow-Leather-Green-it-1558 https://www.bababorses.de/Celine-Medium-Luggage-Tote-Black-Brown-White-Bag-it-2168 https://www.bababorses.de/Louis-Vuitton-Pochette-Voyage-MM-Bag-Damier-Graphite-Canvas-Pixel-N60176-Green-7278-it.html https://www.bababorses.de/Fendi-Black-Snake-Veins-Leather-With-Beige-Ferrari-Leather-Top-handle-Bag-it-469 https://www.bababorses.de/Louis-Vuitton-All-over-Monogram-Sleeveless-Belted-Dress-Navy-1375-it.html https://www.bababorses.de/Louis-Vuitton-Ring-02-560-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV32-76-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55071-Blue-4511-it.html https://www.bababorses.de/Louis-Vuitton-Supreme-Iphone-Case-White-Red-212-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Smooth-Leather-Twist-Shoulder-Bag-MM-Pink-Black-2639-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Cosmetic-Pouch-Bag-M80502-Bouton-de-Rose-Pink-By-The-Pool-Capsule-Collection-4296-it.html https://www.bababorses.de/Louis-Vuitton-Bracelet-21-271-it.html https://www.bababorses.de/Louis-Vuitton-Heel-9.5-cm-Star-Trail-Ankle-Boots-Black-5511-it.html https://www.bababorses.de/Louis-Vuitton-Geronimos-Belt-Bag-M43502-Black-Epi-Leather-2646-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Vavin-Chain-Wallet-N60222-Bordeaux-Red-7221-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Zippy-Coin-Purse-M80408-Cream-Saffron-By-The-Pool-Capsule-Collection-7741-it.html https://www.bababorses.de/Louis-Vuitton-Vintage-Monogram-Vernis-Bleecker-Box-Top-Handle-Bag-Burgundy-4172-it.html https://www.bababorses.de/Prada-Saffiano-Mini-Galleria-Crossbody-Bag-Beige-it-2708 https://www.bababorses.de/Louis-Vuitton-Sunglasses-39-1042-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Leopard-Print-Onthego-Tote-Bag-M44674-Black-White-3232-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Twist-PM-Bag-with-Crystal-embellished-Chain-M55412-White-2630-it.html https://www.bababorses.de/Fendi-Chameleon-Red-Cross-Veins-Leather-Tote-Bag-it-488 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Onthego-Tote-Bag-M44571-Kaki-3270-it.html https://www.bababorses.de/Fendi-Earth-Yellow-Leather-with-Multicolor-Striped-Fabric-Shopping-Handbag-it-771 https://www.bababorses.de/Louis-Vuitton-Croco-Pattern-Petite-Boite-Chapeau-Bag-Black-4090-it.html https://www.bababorses.de/Prada-Saffiano-Small-Double-Handle-Tote-Bag-Light-Gray-Pomice-it-2849 https://www.bababorses.de/Louis-Vuitton-Lvxlol-Speedy-BB-M45202-Golden-3125-it.html https://www.bababorses.de/Louis-Vuitton-Gloria-Flat-Open-Back-Loafers-Monogram-Canvas-5798-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-PM-Monogram-Vernis-leather-IN-MORDORE-4074-it.html https://www.bababorses.de/Replica-Hermes-Steve-H2810-Ladies-Shoulder-Bag-Cow-Leather-it-1428 https://www.bababorses.de/Louis-Vuitton-Noe-bag-M42226-Brown-3496-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Azur-Canvas-I-2260-it.html https://www.bababorses.de/Christian-Dior-Multicolor-PeachYellow-Zipper-Wallet-118-it-223 https://www.bababorses.de/Fendi-By-the-Way-Small-Tricolor-Satchel-Bag-it-2916 https://www.bababorses.de/Prada-Medium-Vitello-Diano-Open-Tote-Bag-Pomice-it-2728 https://www.bababorses.de/Luxury-Hermes-Wallet-H001-Unisex-Wallet-it-1598 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV42-104-it.html https://www.bababorses.de/Prada-Saffiano-Small-Gardeners-Tote-Bag-Blue-it-2803 https://www.bababorses.de/Louis-Vuitton-Sac-Tricot-Bag-Epi-Leather-Red-M52805-2736-it.html https://www.bababorses.de/Louis-Vuitton-Crazy-in-Lock-Strass-Bracelet-Silver-316-it.html