自己用到的一些js技巧

if (top.location != self.location) { top.location = self.location; }

if (top.location == self.location) { top.location='index.htm';} 

 js打印

<script type="text/javascript">

function preview()

{

    bdhtml=window.document.body.innerHTML;

    sprnstr="<!--startprint-->";

    eprnstr="<!--endprint-->";

    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);

    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));

    window.document.body.innerHTML=prnhtml;

    window.print();

}

</script> 

posted @ 2009-12-30 15:03  余魁  阅读(210)  评论(0编辑  收藏  举报