Object problem
Hi everyone,
I want the visitors to my site (not online yet) to decide whether they want a backgroundsound or not. They even can choose what kind of sound they want via a <select>.
The code is below:
<script language="javascript">
var aySound = new Array();
aySound[0] = "silence.wav";
aySound[1] = "groovearmada.wav";
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE|NS? 1:0;
onload=auPreload;
function auPreload()
{
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else
{
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' LOOP='TRUE' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else
{
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon=IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play)
{
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound)
{
if (window.auCon) auCon.control(whSound,true);
}
function stopSound(whSound)
{
if (window.auCon) auCon.control(whSound,false);
}
function okdan()
{
var noiz=document.form1.selekd.options[document.form1.selekd.selectedIndex].text;
if (noiz=='Select backgroundsound')
playSound(0);
if (noiz=='--> No sound <--')
playSound(0);
if (noiz=='Groove Armada')
playSound(1);
}
</SCRIPT>
</HEAD>
<BODY background="b.gif">
<form name=form1>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<Select Name="selekd" onchange="okdan()" class="ucselect">
<option selected>Select backgroundsound</option>
<option>--> No sound <--</option>
<option>Groove Armada</option>
</select>
</td>
</tr>
</table>
</form>
(...)
I got 2 problems:
-IE says: Aucon is no object, which I do not get at all, cause NS accepts this object.
-NS does not loop the wav-file, although I say: LOOP='TRUE'
Who helps me out???
Thanx in advance,
Jack
By the way: you can watch it 'work' at
http://www6.ewebcity.com/uppershelf/b.htm
[This message has been edited by Jack Michaelson (edited 31 March 2000).]
[code] was ommited, just put it back... -Mark
[Edited by Mark Hensler on Feb. 06, 2001 at 01:14 AM]
Shakespeare: onclick || !(onclick)
Vincent Puglia posted this at 22:01 — 1st April 2000.
They have: 634 posts
Joined: Dec 1999
Hi,
Don't really do sound, but...
Offhand, I would say Navigator is choking on the quotes. Try escaping instead of putting doubles inside singles inside doubles.
Regarding IE:
If this is where the error-message is:
auCon=IE? document.all.auIEContainer:auEmb;
check the spelling and case;
Vinny
------------------
GrassBlade: cut&paste javascript
Where the world once stood
the blades of grass cut me still
Jack Michaelson posted this at 09:38 — 3rd April 2000.
He has: 1,733 posts
Joined: Dec 1999
Thanx Vinny,
Gonna try that.
Greetz,
Jack
Jack Michaelson posted this at 08:40 — 4th April 2000.
He has: 1,733 posts
Joined: Dec 1999
No Vinny,
it won't work.
Who's gonna help me??
Jack
Lloyd Hassell posted this at 02:25 — 5th April 2000.
They have: 231 posts
Joined: Feb 2000
I don't know much about embedded sounds but you might want to try loop="-1".
auCon has not been specified as an object so when you try added a property you get an error. Use the following:
auCon = new Object();
:: Lloyd Hassell :: http://www14.brinkster.com/lloydh ::
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.