0

$my_venue 有带空间的数据。例如=“娜娜诺诺”。当我将鼠标悬停在链接上时,它会被空间切断。如果没有空间,它工作正常。

<tr onmouseover="mouse_event(this, 'hlt');" onmouseout="mouse_event(this, '');">
    <?php
    $my_venue= $row['name'];

    echo "<td><a href= http://x.x.x.x:xx/JUNK/search_results.php?user-val=&venue-val=$my_venue&region-val=&lhversion-val=&releaseversion-val=&testtype-val=&api-val=&rate-val=&journaldate-val=&comments-val=&date-val=&record=%25>{$row['name']} </a></td>";
    echo "<td>{$row['region']} </td>";

哦,顺便说一句,我需要空间,因为我需要将此信息传递给数据库,并且在数据库中,数据确实有空间

4

2 回答 2

2

您需要对值进行原始编码并引用属性。尤其是后者是您应该始终做的事情。浏览器可能会因缺乏编码而宽容,但未引用参数中的空格无论如何都会结束它。

echo '<td><a href="http://x.x.x.x:xx/JUNK/search_results.php?user-val=&venue-val='.rawurlencode($my_venue).'&region-val=&lhversion-val=&releaseversion-val=&testtype-val=&api-val=&rate-val=&journaldate-val=&comments-val=&date-val=&record=%25">'.htmlspecialchars($row['name']).'</a></td>';

哦,如果mouse_event()在悬停时添加 CSS 类:您可以使用:hoverCSS 伪类,并且不需要任何 JavaScript。当然,除非您需要支持 IE6,但如果是这种情况,您的问题无论如何都出在其他地方。:)

于 2013-04-16T16:13:23.623 回答
0
$my_venue = str_replace(' ', '%20', $row['name'])
于 2013-04-16T16:13:28.473 回答