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.

<cfoutput>
<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>
       </ol>
     </div>
   </div>

<div class="row">
       <div class="col-lg-3">
                    <div class="panel panel-default">
                       <div class="panel-heading">
                         <h3 class="panel-title">Calendars</h3>
                       </div>
                       <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="#rc.EmployeesCalendars.id#" <cfif isdefined("session.calendartoView")><cfif ListFind(session.calendartoview,rc.EmployeesCalendars.id,',')>checked</cfif></cfif>>&nbsp;<span style="background-color:###rc.EmployeesCalendars.calColor#">&nbsp;</span>&nbsp;#rc.EmployeesCalendars.category#</p>
                             </cfloop>
                                   <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" />
                       </form>
                       </div>
                       </div>

                       <div class="panel panel-default">
                           <div class="panel-heading">
                             <h3 class="panel-title">Tools</h3>
                           </div>
                           <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>
                       </div>             
       </div><!-- col --->

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

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

<script type="text/javascript">
function ClickHereToPrint(val){
   try{ 
       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("<html><head><title>"+val+"</title>");
       oDoc.write("</head><body onload='this.focus(); this.print();'>");
       oDoc.write(oContent + "</body></html>");        
       oDoc.close();        
   }
   catch(e){
       self.print();
   }
}

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

       $('##calendar').fullCalendar({

           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(rc.getEvents.date,"mm/dd/yyyy"))#, #month(dateformat(rc.getEvents.date,"mm/dd/yyyy"))-1#, #day(dateformat(rc.getEvents.date,"mm/dd/yyyy"))#, #hour(rc.getEvents.startTime)#, #minute(rc.getEvents.startTime)#),
                       url: '#event.buildLink("EventCalendar.CalendarDayView")#?DayToView=#dateformat(rc.getEvents.date,"mm/dd/yyyy")#',
                       allDay: false
                   }

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

           eventClick: function(event) {
               // opens events in a custom made fancybox window
               openiFrame(event.url);
               return false;
           }
       });
   });
</script>

<!-- 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>
</cfoutput>

Open in new window

tryportAsked:
Who is Participating?

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

x
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("<html><head><title>"+val+"</title>");
       oIframe.write("</head><body onload='this.focus(); this.print();'>");
       oIframe.write(oContent + "</body></html>");        
       oIframe.close();
0

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
JavaScript

From novice to tech pro — start learning today.