Java脚本中的LImit字符打印输出

时间:2015-06-09 13:02:38

标签: javascript text printing limit

我试图用js文件限制标签上打印的字符数。我遇到问题的代码部分由按钮调用,并从预览框中打印内容。一切正常,除了我试图打印的标题的长度。什么时候我添加代码来限制我得到的字符数: TypeError:title.substring不是函数 title = title.substring(0,11);任何想法

// To allow for the TEMP SLU's to be printed from the main page in alpha order
$("#barcodesku").live('click', function(){
var title=[];
var sku=[];
var first = "";
var second = "";
var indexGlobal = 0;

    $('#acctRecords tbody tr').each(function()
	{
		sku.push($(this).find('#tableSKU').html());
		title.push ($(this).find('#tableTitle').html());
		
                
        });  //end of acctRecords tbody function
    
    //Print the bar codes
		title = title.substring(0,16);
		var x=0;
		for (x=0;x<sku.length;x++){
			
			
                        first += '$("#'+indexGlobal+'").barcode("'+sku[x]+'", "codabar",{barHeight:40, fontSize:30, output:"bmp"});';
			second += '<div class="wrapper"><img src="../images/temp.jpg" /><div id="'+indexGlobal+
			'"></div><div class="fullSKU">&nbsp &nbsp &nbsp '+sku[x]+'</div><br/><div class="title", {title.substring(0,16)}; >'+title[x]+' </div></div><br/><br/>';
			indexGlobal++;
			
 					
 			
					
			}
    var barcode =  window.open('','BarcodeWindow','width=200');
			var html = '<html><head><title>Barcode</title><style type="text/css">'+
   			'.page-break{display:block; page-break-before:always; }'+
			'body{width: 2in;}'+
			'.wrapper{height: 1in;margin-left:10px;margin-top:5px;margin-right:5px;}'+
			'.fullSKU{float: left;}'+
			'.shortSKU{float: right;font-size:25px;font-weight:bold;}'+
			'.title{float: left;}'+
			'</style><script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script><script type="text/javascript" src="../barcode/jquery-barcode.js"></script><script>$(document).ready(function() {'+first+'window.print();window.close();});</script></head><body>'+second+'</body></html>';
			barcode.document.open();
			barcode.document.write(html);
			barcode.document.close();
			
}); // end of click function

1 个答案:

答案 0 :(得分:1)

从你的代码我看到标题是一系列标题。您需要执行以下操作:

requests