在PHP页面的JavaScript功能,导致与PHP标签格式问题
-
13-09-2019 - |
题
我想引用一个JavaScript文件中,含有表排序函数,在一个PHP文件。
一切功能。应当的方式,但一旦我添加下面的代码到我的PHP报告页面就出现问题的原因的选项卡我的导航页面上的格式。同样的问题来了,如果我添加的PHP代码之外的随机document.write
。不是一个巨大的问题,而是难看给用户。
有没有引用JavaScript源文档不会与我的PHP导航页面格式地干扰更好的办法?我觉得有,我不抓一个简单的修补程序。
<script language="JavaScript" src="include/sorttable.js"></script>
也用PHP标签内的所述PHP echo
拨打电话,同样的问题。
下面是用于选项卡中的导航代码格式的问题是关于即将到来的一部分。
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////
function start_page_printer_friendly(
$section = "home",
$headContents = null,
$bodyAttributes = null
)
//////////////////////////////////////////////////////////////////////////////////////////////////
{?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php print $page_title; ?></title>
<link href="/trellis_portal/include/portal.css" media="screen"
rel="Stylesheet" type="text/css" />
<?php if ( ! is_null($headContents)) { print $headContents; } ?>
</head>
<body onload="printpage();" <?php if ( ! is_null($bodyAttributes)) { print $bodyAttributes; } ?>>
<script language="JavaScript">
<!--
function printpage() { window.print(); }
-->
</script>
<br />
<?php
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function start_page( $section = "home",
$subsection = null,
$headContents = null,
$bodyAttributes = null
)
//////////////////////////////////////////////////////////////////////////////////////////////////
{
if (isset($_GET['printer']))
{
start_page_printer_friendly();
return;
}
$section = strtolower($section);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php print $page_title; ?></title>
<?php if ( ! is_null($headContents)) { print $headContents; } ?>
</head>
<body class=" yui-skin-sam" <?php if ( ! is_null($bodyAttributes)) { print $bodyAttributes; } ?>>
<br />
<div id="header">
<ul>
<!--
<li><a class="<?php print tabSelector($section, 'executive'); ?>"
href="/trellis_portal/portal.php?section=executive&title=Executive">Executive</a></li>
<li><a
class="<?php print tabSelector($section, 'community'); ?>"
href="/trellis_portal/portal.php?section=community&title=Community">Community</a></li>
-->
<li><a class="<?php print tabSelector($section, 'trellis'); ?>"
href="/trellis_portal/portal.php?section=trellis&title=Trellis">Trellis</a></li>
<!--
解决方案
我还没有得到你所期望的,但有一件事我已经可以看到:外面的一切简直是换位,从而
?>
<!DOCTYPE...
将在DOCTYPE之前开始引入一个额外的空格(换行)。
另外的脚本的结束( - >)将生成JS语法错误。它是有效的HTML但必须注释。 - 在JS(//>)
其他提示
我真的不明白的情况,但你必须知道,有你的页面上没有任何有关PHP,应用于由PHP只生成HTML / CSS / Javascript代码所发生的。所以,你需要考虑你的HTML代码和看到的问题是那里。然后,您可能需要更新与实际的HTML代码,你的问题。
SCRIPT 标记本身,可以在不影响页面内的元件或布局。
您的问题可能是在其他地方。为了调试这个我会忽略了PHP,并专注于HTML输出,并查找未关闭标签和无效的标记等。
不隶属于 StackOverflow