| | |
Play Sound with javascript DHTML
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
This should work!
If not then try to check you plug-ins...
If not then try to check you plug-ins...
html Syntax (Toggle Plain Text)
<html> <head> <title><!-- Sample --></title>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- function playSound( mysound ) { thisSound = document.getElementById(mysound); thisSound.Play(); } //--> </script>
html Syntax (Toggle Plain Text)
</head> <body> <embed src="someaudiofile.mp3/mid/wav" autostart="false" width="0" height="0" id="sound1" enablejavascript="true" /> <br /> <a href="javascript:void(0);" onmouseover="playSound('sound1');">Play Sound!</a> </body> </html>
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 0
Hello -
I'm new to dynamic webpages, and I need some help.
This thread is relevant to me, but does not exactly answer my question.
The code below generates a webpage that automatically plays a part of a soundfile, depending on what name and start and end times are delivered to it in the PHP part of the code.
The question I have is that in Opera, Firefox/Mozilla everything works perfectly, and you can click on the .gif and the script will run again and the sound will play again. However this is not the case in IE. The script will run, and play part of the section that it is supposed to play, but not all of it, and if it does not play all of it, clicking on the .gif generates a 'null' is null or not an object error. Line 16 Char 1.
Any help would be much appreciated.
P.
<?php
$filename=$_GET['filename'];
$starttime=$_GET['starttime'];
$endtime=$_GET['endtime'];
print '
<html>
<head>
<meta name=Title content="Digital Maya Website Audio">
<meta name=Keywords content="">
<meta http-equiv=Content-Type content="text/html; charset=macintosh">
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<title>Website Title</title>
<script>
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
</head>
<body bgcolor=white lang=EN-US style="border:0;margin=0;align=center">
<div class=Section1>
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width=0
height=0>
<param name="src" value="'.$filename.'">
<param name="scale" value="tofit">
<param name="controller" value="true">
<param name="autoplay" value="true">
<param name="loop" value="false">
<param name="starttime" value="'.$starttime.'">
<param name="endtime" value="'.$endtime.'">
<embed src="'.$filename.'" id="s001" scale=tofit width=1 height=1 align=center controller=false autoplay=true
loop=false starttime="'.$starttime.'" endtime="'.$endtime.'" enablejavascript=true
pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime"></EMBED></OBJECT>
<form>
<img src="http://www.webucateus.com/dotnetnuke/Portals/0/Cache/images/soundIcon.gif" height=50 onClick="EvalSound(\'s001\')">
</form>
</div>
</body>
</html>
';
?>
I'm new to dynamic webpages, and I need some help.
This thread is relevant to me, but does not exactly answer my question.
The code below generates a webpage that automatically plays a part of a soundfile, depending on what name and start and end times are delivered to it in the PHP part of the code.
The question I have is that in Opera, Firefox/Mozilla everything works perfectly, and you can click on the .gif and the script will run again and the sound will play again. However this is not the case in IE. The script will run, and play part of the section that it is supposed to play, but not all of it, and if it does not play all of it, clicking on the .gif generates a 'null' is null or not an object error. Line 16 Char 1.
Any help would be much appreciated.
P.
<?php
$filename=$_GET['filename'];
$starttime=$_GET['starttime'];
$endtime=$_GET['endtime'];
print '
<html>
<head>
<meta name=Title content="Digital Maya Website Audio">
<meta name=Keywords content="">
<meta http-equiv=Content-Type content="text/html; charset=macintosh">
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<title>Website Title</title>
<script>
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
</head>
<body bgcolor=white lang=EN-US style="border:0;margin=0;align=center">
<div class=Section1>
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width=0
height=0>
<param name="src" value="'.$filename.'">
<param name="scale" value="tofit">
<param name="controller" value="true">
<param name="autoplay" value="true">
<param name="loop" value="false">
<param name="starttime" value="'.$starttime.'">
<param name="endtime" value="'.$endtime.'">
<embed src="'.$filename.'" id="s001" scale=tofit width=1 height=1 align=center controller=false autoplay=true
loop=false starttime="'.$starttime.'" endtime="'.$endtime.'" enablejavascript=true
pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime"></EMBED></OBJECT>
<form>
<img src="http://www.webucateus.com/dotnetnuke/Portals/0/Cache/images/soundIcon.gif" height=50 onClick="EvalSound(\'s001\')">
</form>
</div>
</body>
</html>
';
?>
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Search for string in a textfile using javascript
- Next Thread: encodeURI & decodeURI
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor decimal dependent design disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl listbox math media microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player post problem progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n





