[Javascript] Buttons and Sound in FireFox

charlie_chan charlie_chan at cox-internet.com
Thu May 19 07:28:43 CDT 2005


Can someone explain to me what to do to make this work in FireFox.
What I want to do is make the sounds/music play in FireFox without
the media play popping up over the main window.  I can make most
everything work in IE.  The only thing I could get FireFox to do is
play some background music.  I have commented the code to explain
what I tried while experimenting.  Here is the code.

<?xml version="1.0" ?>

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html" indent="yes" />

<xsl:template match="/">
<html xmlns:t ="urn:schemas-microsoft-com:time">

<!-- This following script for the first button works in IE but not 
FireFox. -->
<script language="javascript">
<xsl:comment>
<![CDATA[
function playA_Sound()
{ this.location.href='lulu.mp3'; }
]]>
//</xsl:comment>
</script>

<!-- The following script for the second button works in IE but not 
FireFox. -->
<script language="javascript">
<xsl:comment>
function playB_Sound(sfile)
{
this.location.href=sfile;
}
//</xsl:comment>
</script>

<!-- <bgsound src="chpv62[1].wav" class="intro" /> -->
    <link rel="stylesheet" type="text/css" href="my_bookstyle.css" />
<head>

    <?IMPORT namespace="t" implementation="#default#time2" ?>

    <title>MY LIBRARY - SORTED BY TITLE</title>
</head>
<body>
<!-- Window Media Play 7 and above
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6."><param 
name="filename" value="lulu.mp3"

/></object>
-->

<!-- .rpn is RealPlayer, .wmp is Win Media Player  This will make a 
non-working player in FireFox-->

<!-- <embed src="plugin.wmp" width="350" height="36" nojava="true" 
controls="ControlPanel" console="one" /> -->

<!-- The following causes lulu to autoplay in FireFox as background 
sound. -->
<!--
<object name="lulu" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="console" value="one" />
<param name="controls" value="ControlPanel" />
<param name="src" value="lulu.mp3" />
</object>
-->

<!--
<embed id="lulu" name="lulu" src="lulu.mp3" loop="false" 
autostart="false" hidden="true" />
-->

<!-- Uncomment this and a copy of realplayer appears.  A player will 
also appear in FireFox but not work.
<embed src="plugin.rpm" width="350" height="36" nojava="true" 
controls="ControlPanel" console="one" />
-->

<!-- FireFox cannot read the following code. -->
<!-- <object id="lulu" 
classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="350" 
height="36"> -->
<object name="lulu" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="src" value="lulu.mp3" />
<param name="controls" value="ControlPanel" />
<param name="console" value="one" />
<param name="autostart" value="false" />
<embed  name="lulu" src="lulu.mp3" loop="false" autostart="false" 
hidden="true" />
<embed src="plugin.wmp" width="350" height="36" nojava="true" 
controls="ControlPanel" console="one" />
</object>

<t:audio id="lulu" src="lulu.mp3" style="behavior:url('#default#time')" />
    <table>
        <tr align="right"><td>BOOKS SORTED BY TITLE</td><td><img 
src="./CharlieChan_bw2.jpg"

/></td></tr>
        <tr><td align="left"><a href="mainSubject.xml" tabindex="0">Sort 
by Subjects</a></td>
            <td align="right"><a href="mainAuthors.xml" 
tabindex="1">Sort by Authors</a></td></tr>
        <tr><td align="center">
            <xsl:element name="button" > <!-- FIRST BUTTON -->
                <xsl:attribute name="onClick" >playA_Sound()</xsl:attribute>
                BUTTON ONE</xsl:element> </td>
            <td><xsl:element name="button" > <!-- SECOND BUTTON -->
                <xsl:attribute name="onClick" 
 >playB_Sound('lulu.mp3')</xsl:attribute>
                BUTTON TWO</xsl:element> </td></tr>
    </table>

    <!-- Example of using the document( ) to include a source tree from 
a separate XML document -->
    <xsl:for-each select="document('data.xml') /data/item/."><!-- Notice 
the way this code ends -->
        <xsl:sort data-type="text" select="normalize-space(title)" 
/><!-- NOTICE THE data-type ENTRY -->
            <table>
                <xsl:call-template name="aTable" /><!-- calling a named 
template -->
            </table>
            <br />
    </xsl:for-each>

</body>
</html>
</xsl:template>

<!--
I used HTML tags instead of XSLT element tags to display the data in 
this table
because it is easier to work with when using a CSS document.
-->
<xsl:template name="aTable">
    <tr class="highlightBlue"><td class="aBorderTL"> TITLE </td><td 
class="aBorderTR"><xsl:value-of select="title"

/></td></tr>
    <tr><td>EDITION</td><td><xsl:value-of select="edition" /></td></tr>
    <tr><td>COPYRIGHTED</td><td><xsl:value-of select="copyrighted" 
/></td></tr>
    <!-- for-each loop -->
    <xsl:for-each select="./authors/author/LName">
        <xsl:sort data-type="text" order="ascending" 
select="normalize-space(./authors/author/LName)" />
        <tr><td class="aBorderML">AUTHOR/s</td><td class="aBorderMR">
            <xsl:value-of select="parent::author/FName" /> <xsl:value-of 
select="' '" /> 
            <xsl:value-of select="parent::author/MName" /> <xsl:value-of 
select="' '" />
            <xsl:value-of select="parent::author/LName" /> <xsl:value-of 
select="' '" />
            <xsl:value-of select="parent::author/degree" /> 
<xsl:value-of select="*/*" />
        </td></tr>       
    </xsl:for-each>
    <tr><td>PUBLISHER</td><td><xsl:value-of select="publisher" /></td></tr>
    <tr><td>ISBN</td><td><xsl:value-of select="isbn" /></td></tr>
    <tr><td>LCCN</td><td><xsl:value-of select="lccn" /></td></tr>
    <tr><td>PRICE</td><td><xsl:value-of select="price" /></td></tr>
    <tr><td class="aBorderBL">SUBJECT</td><td 
class="aBorderBR"><p><xsl:value-of select="subject"

/></p></td></tr>

</xsl:template>
</xsl:stylesheet>




More information about the Javascript mailing list