<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body >
<button onclick="me('${message}');">hello</button>
<div id="play">
</div>
<div id="p">
</div>
</body>
<script type="text/javascript">
function me(mes)
{
switch(mes){
case 'Knowing our Numbers':
var newElement = "<object id='objViewer' width='250' height='250' type='video/x-ms-asf' data='Wildlife.wmv' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'><param name='url' value='Wildlife.wmv'><param name='filename' VALUE='Wildlife.wmv'><PARAM name='autostart' VALUE='0'><param name='uiMode' value='full'><param name='autosize' value='1'><param name='playcount' value='1'><EMBED TYPE='application/x-mplayer2' src='Wildlife.wmv' NAME='MediaPlayer' id='wmvViewer' autostart='false' WIDTH='250' HEIGHT='250' ShowControls='1' ShowStatusBar='0' ShowDisplay='0'></EMBED></object><br/>";
$("#p").html(newElement);
alert(mes);
break;
case 'Whole Numbers':
alert(mes);
break;
}
}
</script>
</html>
在上面的代码中,我试图将switch case变量传递给html元素,但它不能正常工作。我需要根据脚本中的案例选择播放视频,我的代码中的错误给了我解决的想法
提前致谢
答案 0 :(得分:1)
将此添加到头部
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>