我尝试在我的 asp.net 站点中实现以下小部件:
<div style="width: 175px; margin: 0px; padding: 0px; text-align: right; background-color:#FFFFFF;">
<img src="http://fahrplan.sbb.ch/img/igm-sbblogo.gif" width="110" height="18" alt="SBB|CFF|FFS" />
<h1 style="width:175px; background-color: #DDDDDD; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight: bold; padding: 2px 0px; margin: 0; height: 15px; text-align: left;clear:both;"> Fahrplan</h1>
<div style="width: 100%; background-color: #F8F8F8; margin: 0; padding: 0px;" summary="Layout">
<form action="http://fahrplan.sbb.ch/bin/query.exe/dn?externalCall=yes&DCSext.wt_fp_request=partner_mini" name="formular" method="post" style="display:inline" target="_blank">
<input type="hidden" name="queryPageDisplayed" value="yes">
<table cellspacing="0" cellpadding="4" style="width: 170px; margin: 2px;" class="ig">
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Von:
</th>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;" colspan="2">
<input type="hidden" name="REQ0JourneyStopsSID" value="A=1@O=Stettbach, Bahnhof@X=8596132@Y=47397270@U=85@L=008591065@B=1@p=1338878028@">
<span style="font-weight:bold;">Stettbach, Bahnhof</span>
</td>
</tr>
<tr>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<select name="REQ0JourneyStopsZA" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 60px; font-size:11px; margin:0px 0px;">
<option selected="selected" value="7">Nach:</option>
<option value="1">Bhf./Haltest.</option>
<option value="2">Ort, Strasse Nr.</option>
<option value="4">Sehenswürdigkeit</option>
</select>
</td>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;" colspan="2">
<input type="text" name="REQ0JourneyStopsZG" value="" size="16" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 100px; height: 18px; font-size: 11px" accesskey="t" tabindex="2">
<input type="hidden" name="REQ0JourneyStopsZID">
</td>
</tr>
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Datum:
</th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<b>08.06.12</b>
<input type="hidden" name="REQ0JourneyDate" value="08.06.12" accesskey="d">
</td>
</tr>
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Zeit:
</th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<input type="text" name="REQ0JourneyTime" value="11:02" size="5" maxlength="5" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 100px; height: 18px; font-size: 11px" accesskey="c" tabindex="4">
</td>
</tr>
<tr>
<th> </th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<input class="radio" type="radio" name="REQ0HafasSearchForw" value="1" checked style="margin-right:3px;">Abfahrt
<br /><input class="radio" type="radio" name="REQ0HafasSearchForw" value="0" style="margin-right:3px;">Ankunft
</td>
</tr>
<tr>
<td colspan="2" style="text-align:left;">
<input type="hidden" name="start" value="Suchen">
<input type="submit" name="start" value="Verbindung suchen" tabindex="5" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; width:130px; vertical-align: middle; cursor:pointer; -moz-border-radius: 3px 3px 3px 3px; background-color:#EE0000; border:1px solid #B20000; color:#FFFFFF; font-weight:bold; height:auto; line-height:20px; padding:0px 10px; text-decoration:none; white-space:nowrap;">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:left;">
<a style="font-family:Arial,Helvetica,sans-serif; font-size:12px; text-align:left; margin-top:4px; color: #6B7786; text-decoration:none; display:block;" href="http://www.sbb.ch/166" target="_blank" title="Aktuelle Informationen zu Streiks und grösseren Unterbrüchen im Schienenverkehr."><img src="http://fahrplan.sbb.ch/img/one/icon_arrow_right.png" alt="" style="vertical-align:top; padding-right:2px; border:none;" />Bahnverkehrsinformation</a>
</td>
</tr>
</table>
</form>
</div>
</div>
<script language="JavaScript1.2" type="text/javascript">
/* <![CDATA[ */
var time=new Date();
var hour = time.getHours(); hour=(hour<10)? '0'+hour:hour;
var minute = time.getMinutes();minute=(minute<10)? '0'+minute:minute;
var travelTime = hour+':'+minute;
document.formular.REQ0JourneyTime.value=travelTime;
// /* ]]> */
</script>
代码来源: http://fahrplan.sbb.ch/bin/help.exe/en?application=INPUTGEN& tpl=inputgen_start
当我创建一个普通的 HTML 站点时,小部件可以正常工作。
但是在asp站点中,javascript存在问题。在“document.formular.REQ0JourneyTime.value=travelTime;”行中 出现此错误消息:
“JScript 运行时错误:无法检索属性“REQ0JourneyTime”值:对象为空或未定义。”
我认为这个问题与小部件的表单标签和后期操作有关,但我不知道,它到底是什么:S
有人知道如何解决这个问题吗?非常感谢!
迈克尔