Print Page tests

Chrome was acting strange... had to fiddle

HTML

<script src="https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js"></script>
<div style="padding: 10px;">
<a href="#" onclick="printPage();">Print with a link</a>
<br>
<input type="button" value="Print with a button?" onclick="printPage()"/>
</div>



<div id="log" class="log"></div>

CSS

.runButton {
    width:   125px;
    margin:  20px;
}
.log {
   padding:10px; 
    margin: 20px; 
    border: 1px dotted #ccc; 
    color:#888; 
    font-face: arial; 
    font-size:12px; 
    background: #fbfbfb; 
}

JavaScript

/* ************************************ */

function printPage() {
    debug();
    try {
        debug("Printing page (?)");
        window.print();
    } catch (e) {
        debug("Error caught:", e);
    }


    return false;
}






/* ************************************ 
 _____ ___ __  __ ___ _      _ _____ ___ 
|_   _| __|  \/  | _ \ |    /_\_   _| __|
  | | | _|| |\/| |  _/ |__ / _ \| | | _| 
  |_| |___|_|  |_|_| |____/_/ \_\_| |___|
                                         
************************************  */

function debug(message, value) {
    var outMessageHTML = message;
    var outMessageString = message;
    if (typeof value !== "undefined" && value !== null) {
        outMessageHTML += "&nbsp;&nbsp;&nbsp;&nbsp;[" + value + "]";
        outMessageString += "    [" + value + "]";
    }
    if ($("#log").html() !== "") {
        $("#log").append("<br>");
    }
    $("#log").append(outMessageHTML);

    if (window.console && console.log) {
        if (typeof message == "undefined") {
            outMessageString = " ";
        }
        console.log(outMessageString);
    }
}
$("#theButton").live('click', function() {
    runTest();
});