JavaScript Click to Print Function Help

This page USED to work and became persnickety. I'd love some help. If there's a problem here I don't see it.

<cfset theCount = 1>
   <div class="row">
     <div class="col-sm-12">
       <ol class="breadcrumb">
         <li><a href="#event.buildLink('main.index')#">Home</a></li>
         <li class="active">Events Calendar</li>

<div class="row">
       <div class="col-lg-3">
                    <div class="panel panel-default">
                       <div class="panel-heading">
                         <h3 class="panel-title">Calendars</h3>
                       <div class="panel-body">
                         <form name="calendar-Form" id="calendar-form" method="get" action="#event.buildLink('EventCalendar.ShowCalendar')#" class="form-horizontal" role="form">
                           <cfloop query="rc.EmployeesCalendars">
                                   <p><input type="checkbox" id="viewCalendar" name="viewCalendar" value="" <cfif isdefined("session.calendartoView")><cfif ListFind(session.calendartoview,,',')>checked</cfif></cfif>>&nbsp;<span style="background-color:###rc.EmployeesCalendars.calColor#">&nbsp;</span>&nbsp;#rc.EmployeesCalendars.category#</p>
                                   <p> <input type="checkbox" id="regonly" name="regonly" value="1" <cfif isdefined("rc.regOnly")>checked</cfif>/><span>&nbsp;</span>&nbsp;Only registered for events</p>
                       <input type="submit" name="btnSubmit" id="btnSubmit" value="Search" class="btn btn-primary btn-block" />

                       <div class="panel panel-default">
                           <div class="panel-heading">
                             <h3 class="panel-title">Tools</h3>
                           <div class="panel-body">
                               <a class="btn btn-primary btn-block" onclick="ClickHereToPrint('#session.providername# Event Calendar Print Out');" href="javascript:;">Print Calendar</a>
       </div><!-- col --->

       <div class="col-lg-9">
             <div id="divToPrint">
                 <div class="table-responsive">
                   <div id='calendar'></div>

<iframe id='ifrmPrint' src='##' style="width:0px; height:0px;"></iframe>

<script type="text/javascript">
function ClickHereToPrint(val){
       var oIframe = document.getElementById('ifrmPrint');
       var oContent = document.getElementById('divToPrint').innerHTML;
       var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
       if (oDoc.document) oDoc = oDoc.document;
       oDoc.write("</head><body onload='this.focus(); this.print();'>");
       oDoc.write(oContent + "</body></html>");        

$(document).ready(function() {
       var date = new Date();
       var d = date.getDate();
       var m = date.getMonth();
       var y = date.getFullYear();


           header: {
               left: 'title',
               //center: ''
               right: 'prev,next today'

           events: [
               <cfif rc.getEvents.recordcount>
                   <cfoutput query="rc.getEvents">
                       color: <cfif len(calColor)>'###calColor#'<cfelse>'##6699CC'</cfif>,
                       title: '#event_name#',
                       start: new Date(#year(dateformat(,"mm/dd/yyyy"))#, #month(dateformat(,"mm/dd/yyyy"))-1#, #day(dateformat(,"mm/dd/yyyy"))#, #hour(rc.getEvents.startTime)#, #minute(rc.getEvents.startTime)#),
                       url: '#event.buildLink("EventCalendar.CalendarDayView")#?DayToView=#dateformat(,"mm/dd/yyyy")#',
                       allDay: false

                   <cfif theCount LT rc.getEvents.recordCount>,</cfif>
                   <cfset theCount = theCount+1>

           eventClick: function(event) {
               // opens events in a custom made fancybox window
               return false;

<!-- page specific includes --->
<link rel='stylesheet' type='text/css' href='includes/fullcalendar-1.6.4/fullcalendar/fullcalendar.css' />
<script type='text/javascript' src='includes/fullcalendar-1.6.4/fullcalendar/fullcalendar.min.js'></script>

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Any console messages and does not not work in any browser?

Perhaps name the iframe and try

       var oIframe = document.ifrmPrintName.document;
       var oContent = document.getElementById('divToPrint').innerHTML;
       oIframe.write("</head><body onload='this.focus(); this.print();'>");
       oIframe.write(oContent + "</body></html>");        

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.