JavaScript函数在PHP页面上不起作用

dkqlctbz  于 2022-12-26  发布在  PHP
关注(0)|答案(2)|浏览(128)

考虑:

<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() function not found!!!

tvokkenx

tvokkenx1#

script标记未关闭。
关闭脚本标记:

<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">
xpszyzbs

xpszyzbs2#

照普拉迪普·辛格的回答去做。
我猜你用的是CodeIgniter?
如果是,请确保您已经加载了“url”助手。
您可以做的另一个步骤是查看文件的源代码,并检查JavaScript的每个链接。
检查你的$config ['base_url'].结尾应该有一个斜线.

相关问题