簡體   English   中英

在功能(jsp)中混合javascript和html

[英]mix javascript and html in a function (jsp)

作為一個新手,我在努力地了解如何在一個jsp中運行的同一函數中“混合” HTML和Javascript,以及是否允許這樣做。 如果我嘗試“混合代碼”,該功能將無法運行。

我有一個sql查詢測試,它返回一個單元格是否有一個“照片”指示符,如果是,我要啟動網絡攝像頭代碼,即

<c:if test="${row.ftypeid==3}">
<script>
Camera();
</script>

然后,啟動網絡攝像頭的功能將類似於-

function Camera{
<tr>
<td width="200px"><b>Webcam Photo</b></td>
<td>
<input type="file" name="photo"/>
<br>
<script language="JavaScript">
webcam.set_api_url( 'upload.jsp' );
webcam.set_quality( 90 ); // JPEG quality (1 - 100)
webcam.set_shutter_sound( true ); // play shutter click sound
document.write( webcam.get_html(320, 240) );
</script>
<br>
<input type=button value="Configure..." onClick="webcam.configure()">&nbsp;
<input type=button value="Take Snapshot" onClick="take_snapshot()">
<br>

jsp中的常規過程似乎只是javascript,並且完全包含在標記中。 是否可以通過這種方式“混合”代碼?

如果我嘗試在“ if test”(還顯示任何現有存儲的照片)之后立即添加網絡攝像頭代碼,則這似乎“破壞”了存儲的照片,然后產生了錯誤(並顯示2個瀏覽按鈕而不是1個),如果已保存。

</c:if>
<c:if test="${row.ftypeid==3}">
<input type="file" name="f${row.sequence}">
<tr>
<td width="200px"><b>Webcam Photo</b></td>
<td>
<input type="file" name="photo"/>
<br>
<script language="JavaScript">
webcam.set_api_url( 'upload.jsp' );

思想表示贊賞。

關於活動

不,這是不允許的-我想你的意思是

<c:if test="${row.ftypeid==3}">
  <tr>
  <td width="200px"><b>Webcam Photo</b></td>
  <td>
  <input type="file" name="photo"/>
  <br>
  <script language="JavaScript">
  webcam.set_api_url( 'upload.jsp' );
  webcam.set_quality( 90 ); // JPEG quality (1 - 100)
  webcam.set_shutter_sound( true ); // play shutter click sound
  document.write( webcam.get_html(320, 240) );
  </script>
  <br>
  <input type=button value="Configure..."   onClick="webcam.configure()">&nbsp;
  <input type=button value="Take Snapshot" onClick="take_snapshot()">
  <br>
</c:if>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM