SimonMc
03-25-2006, 04:59 AM
Using the object tag, how can I create a html hyperlink that when clicked opens up a sized window and plays a sound clip? Without needing the user to have special software on their PC.
Simon
Simon
![]() | View Full Version : Object Tag for Sound SimonMc 03-25-2006, 04:59 AM Using the object tag, how can I create a html hyperlink that when clicked opens up a sized window and plays a sound clip? Without needing the user to have special software on their PC. Simon EVILISCIOUS 03-25-2006, 06:55 AM Simplest way to playback audio on a webpage-.. add this tag to your page- <bgsound src="clip.wav"> Save the page with this tag as clip.html to work with what follows.. To launch the new window, with size defined.. put this in the head section and edit the height and width values <script type="text/javascript">var newwindow; function new(url) { newwindow=window.open(url,'name','height=350,width=500'); if (window.focus) {newwindow.focus()} } </script> Create the link to the new window as follows <a href="javascript:new('http://www.yoursite.com/clip.htm');">link anchor text</a> EVILISCIOUS 03-25-2006, 06:57 AM You can do away with the bgsound tag and use the object tag in clip.htm instead if you'd prefer that. SimonMc 03-25-2006, 08:23 AM You can do away with the bgsound tag and use the object tag in clip.htm instead if you'd prefer that. What code would I use to use the object tag so it allows the clip to play automatically when the window launches? Cheers for your help. EVILISCIOUS 03-25-2006, 08:30 AM <object data="clip.mp3" type="audio/x-mp3"> if it's wav change type to audio/x-wav EVILISCIOUS 03-25-2006, 08:32 AM sorry I left out data, post edited SimonMc 03-25-2006, 11:08 AM When I add this code to my webpage test.htm I have a problem. This code comes up with an error: <a href="javascript:new('http://mywebsite.com/clip.htm');">link anchor text</a></p> The error reads: Line 11 Char 10 Error Expected '(' Code:0 URL: http://mywebsite.com/test.htm What is wrong? EVILISCIOUS 03-25-2006, 11:17 AM Did you add the javascript to the head section of the page? SimonMc 03-26-2006, 03:22 AM OK...The head section :-) When I move the javascript to the head section I get this error: Line 1 Char 1 Error Object doesn't support this action Code:0 URL: http://mywebsite.com/test.htm |