gpt4 book ai didi

javascript - IE8 及以下版本中的 InnerHTML 问题

转载 作者:搜寻专家 更新时间:2023-11-01 05:24:37 24 4
gpt4 key购买 nike

我正在为时间表过滤系统编辑以前开发人员的一些代码。我自己解决这个问题的方法是使用 jQuery,所以我在调试这个问题时遇到了一些问题。 IE 中的 Javascript 似乎有问题。

这是出现问题的代码:

Javascript:

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("showtimetable").innerHTML=xmlhttp.responseText;
jQuery('div #moreInfo a').each(function()
{
var $link = jQuery(this);
var $dialog = jQuery('<div></div>')
.load($link.attr('href') + ' #content')
.dialog
({
autoOpen: false,
title: $link.attr('title'),
width: 600
});

$link.click(function()
{
$dialog.dialog('open');
return false;
});

和标记:

<div id="showtimetable">
<table class="tidytable">
<thead>
<tr>
<th width="20%">
Venue
</th>
<th width="18%">
Session
</th>
<th width="18%">
Age
</th>
<th width="15%">
<?php echo JText::_('COM_TIMETABLE_HEADING_GROUP'); ?>
</th>
<th width="10%">
<?php echo JText::_('COM_TIMETABLE_HEADING_WEEKDAY'); ?>
</th>
<?php /*<th width="13%">
Activity
</th>*/ ?>
<th width="14%">
Time
</th>
<th width="5%">
Info
</th>

</tr>
</thead>
<tfoot>
<tr>
<td colspan="13">
<?php //echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach($this->items as $i => $item): ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<?php if($item->centreDescription!=''){echo '<a href="'.$item->centreDescription.'" >'.$item->centre.'</a>';}
else {echo $item->centre;}?>
</td>
<td>
<?php echo $item->class;?>
</td>
<td>
<?php echo $item->ageRange;?>
</td>
<td>
<?php echo $item->gn;?>
</td>
<td>
<?php TimeTablesHelper::getWeekday($item->weekday);?>
</td>
<?php /*<td>
<?php echo $item->activity; ?>
</td>*/?>
<td>
<?php echo substr($item->startTime,0,5); ?> - <?php echo substr($item->endTime,0,5); ?>
</td>
<td width="5%">
<?php if($item->bookingInfo!=''){?>
<div id="moreInfo">
<a href="moreinfo.php?id=<?php echo $item->id;?>" title="More Details...">+</a>
</div>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

这是 xml 响应中的内容:

<form action="/component/timetable/" method="post" name="adminForm">
<table class="tidytable">
<thead>
<tr>
<th width="20%">
Venue
</th>
<th width="18%">
Session
</th>
<th width="18%">
Age
</th>
<th width="15%">
Group </th>
<th width="10%">
Weekday </th>
<th width="14%">
Time
</th>
<th width="5%">
Info
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="13">
</td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td>
Heywood Civic Centre </td>
<td>
50+ Bowls </td>
<td>
Aged 50 plus </td>
<td>
50 Plus </td>
<td>
Thursday </td>
<td>
13:00 - 16:00 </td>
<td width="5%">
<div id="moreInfo">
<a href="/moreinfo.php?id=303" title="More Details...">+</a>
</div>

</td>
</tr>
</tbody>
</table>
<input type="hidden" name="task" value="" />
</form>

这在 Firefox 和 IE9 中运行良好,但在 IE8 及以下版本中我收到 SCRIPT601: unknown runtime error fitness-classes, line 564 character 7 它指的是 javascript 中带有 innerHTML 函数的行。

我不确定为什么会出现这个问题,但它阻止了任何 Javascipt 的工作。

有人知道为什么会发生这种情况吗?

非常感谢!

最佳答案

如果您不遵循 W3C 标签建议,就会发生此错误。 IE 对此非常挑剔,而 Firefox 则不然。您可以在此处阅读更多信息:http://blog.rakeshpai.me/2007/02/ies-unknown-runtime-error-when-using.html

这里有一个可能对您有帮助的类似问题:Fixing "unknown runtime error" in IE8

这是关于同一件事的另一个链接,特别是“表单中的表单”问题:http://jadendreamer.wordpress.com/2009/06/02/internet-explorer-fix-unknown-runtime-error-using-innerhtml-ajax/

关于javascript - IE8 及以下版本中的 InnerHTML 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13817999/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com