2013-01-25 229 views
0

我在js控制檯中得到一個「SCRIPT5009:'channel_click'未定義」的IE9錯誤。該代碼在Chrome瀏覽器中使用chrome &,但在點擊鏈接以在IE9中啓動js序列時突然停止。js控制檯中的參考錯誤-SCRIPT5009:'channel_click'未定義

我一直在努力,但沒有成功摸不着頭腦,但我做了什麼是定時的一系列事件的發生,其中:

1) onclick - toggle div to hide 
2) wait 1500 
3) open print command 
- User closes the window to return to page 
4) wait 3500 toggle div to show again 

我之所以這樣做,這是我不希望打印預覽以在用戶決定打印頁面時拾取這些系列的div。

Javacript:

<script> 
//WAITS UNTIL EXCESS IS HIDDEN THEN FIRES PRINT COMMAND 
function channel_click(){ 

// anon wrapper function, 2 second delay 
setTimeout(function() { 
window.print();return false; 
} , 1500); 

} 
</script> 


<script> 
//HIDES EXCESS IN PREP FOR FIRING PRINT COMMAND PREVIOUS FUNCTION EXECUTES IN BETWEEN FOLLOWING FUNCTIONS 
$(".hideshow").click(function() { 
$("#header,#footer").toggle("slow"); 

setTimeout(function() { 
$("#header,#footer").toggle("slow"); 
} , 3500); 
$('.modal-backdrop').hide(); 
}); 
</script> 

HTML:

<a href="#" role="button" class="hideshow" onclick="channel_click()">Print Preview</a> 

<div id="header"> 
    <div class="pull-left"> 
    <h1>Edt Mode</h1> 
    <h6 style="padding-bottom: 30px;">Some informational text here</h6> 
</div> 

<div> 
    <div class="pull-left"> 
    <h1>PRINT ME!</h1> 
    <h6 style="padding-bottom: 30px;">PRINT ME - PRINT ME - PRINT ME</h6> 
</div> 

<div id="footer"> 
    <div class="pull-left"> 
    <h1>Edt Mode</h1> 
    <h6 style="padding-bottom: 30px;">Some informational text here</h6> 
</div> 

<div class="model-backdrop">wow this is some more text</div> 
+0

實際上你的代碼看起來很好,你只是缺少'

0

嘗試從您的錨標記的onclick刪除:

<a href="#" role="button" class="hideshow">Print Preview</a> 

JS:

<script type="text/javascript"> 
function channel_click(){  
    // anon wrapper function, 2 second delay 
    setTimeout(function() { 
     window.print();return false; 
    } , 1500);  
} 

    $(document).ready(function() { //add this 
     $(".hideshow").click(function (e) { 
      e.preventDefault(); 
      $("#header,#footer").toggle("slow"); 
      channel_click(); //call print 

      setTimeout(function() { 
       $("#header,#footer").toggle("slow"); 
      } , 3500); 
      $('.modal-backdrop').hide(); 
     }); 
    }); 
0

出的是沒有形成良好的HTML是,我沒有看到什麼不對勁的地方。也許你可以給我們提供完整的標記?