Javascript函数无法在php页面上运行

时间:2012-01-24 06:14:40

标签: php javascript

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<!-- js start-->   
    <script src="<?=base_url();?>js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="<?=base_url();?>js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
    <script src="<?=base_url();?>js/aspectza.js" type="text/javascript"></script>
<!-- js end-->  


  <!-- BEGIN: load jquery plugins -->
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js">
  <!-- END: load jquery plugins -->

<!--<script src="http://code.jquery.com/jquery-latest.js"></script>
   <link rel="stylesheet" href="<?=base_url();?>css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" />
  <script src="<?=base_url();?>js/jquery.validationEngine-en.js" type="text/javascript"></script>
  <script src="<?=base_url();?>js/jquery.validationEngine.js" type="text/javascript"></script>-->

    <SCRIPT LANGUAGE="JavaScript">

        function printSelect()
        {

            if (document.getElementById !=null)
            {
                var html='<HTML>\n<HEAD>\n';

                if (document.getElementsByTagName != null)
                {
                    var headTags = document.getElementsByTagName("head");
                    if (headTags.length > 0)
                    html += headTags[0].innerHTML;
                }

                html += '\n</HE' + 'AD>\n<BODY>\n';

                html+='\n<TABLE>\n';

                var printSelect = document.getElementById("printSelect");


                if (printSelect != null)
                {
                    html += printSelect.innerHTML;

                }
                else
                {
                    alert("Could not find the printReady section in the HTML");
                    return;
                }
                html+= '\n</TA' + 'BLE>\n</FO' + 'RM>';
                html += '\n</BO' + 'DY>\n</HT' + 'ML>';

                var printWin = window.open("","printForm");
                printWin.document.open();
                printWin.document.write(html);
                printWin.document.close();
                printWin.print();
                printWin.close();

            }
            else
            {
                alert("Sorry, the print ready feature is only available in modern browsers.");
            }
        }
    </script>

    <form name="summary" OnSubmit="return printSelect();"> 

<input type="image" src="icon.jpg""  name="print">

找不到printSelect()函数!!!

enter image description here

2 个答案:

答案 0 :(得分:0)

脚本标签未关闭
关闭脚本标记

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<!-- js start-->   
    <script src="<?=base_url();?>js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="<?=base_url();?>js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
    <script src="<?=base_url();?>js/aspectza.js" type="text/javascript"></script>
<!-- js end-->  


  <!-- BEGIN: load jquery plugins -->
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
  <!-- END: load jquery plugins -->



    <SCRIPT LANGUAGE="JavaScript">

        function printSelect()
        {

            if (document.getElementById !=null)
            {
                var html='<HTML>\n<HEAD>\n';

                if (document.getElementsByTagName != null)
                {
                    var headTags = document.getElementsByTagName("head");
                    if (headTags.length > 0)
                    html += headTags[0].innerHTML;
                }

                html += '\n</HE' + 'AD>\n<BODY>\n';

                html+='\n<TABLE>\n';

                var printSelect = document.getElementById("printSelect");


                if (printSelect != null)
                {
                    html += printSelect.innerHTML;

                }
                else
                {
                    alert("Could not find the printReady section in the HTML");
                    return;
                }
                html+= '\n</TA' + 'BLE>\n</FO' + 'RM>';
                html += '\n</BO' + 'DY>\n</HT' + 'ML>';

                var printWin = window.open("","printForm");
                printWin.document.open();
                printWin.document.write(html);
                printWin.document.close();
                printWin.print();
                printWin.close();

            }
            else
            {
                alert("Sorry, the print ready feature is only available in modern browsers.");
            }
        }
    </script>

    <form name="summary" OnSubmit="return printSelect();"> 

<input type="image" src="icon.jpg""  name="print">

答案 1 :(得分:0)

在上面做。加,

我猜你在使用codeigniter?

如果是, 确保你已经加载了“url”帮助器。

您可以执行的另一个步骤是查看文件来源,并检查您的javascript的每个链接。

检查你的$ config ['base_url']。最后应该有一个斜线。