use <script> inside function ?

B

bunch92

Hi,
I am stuck with ideas guys ....

Can someone please tell me what I did wrong in the code below ? I think
it might be the <script> tag inside the function ?

Thank you


<SCRIPT LANGUAGE="JavaScript">
function playasound(thesound,thename,themethod)
{
if (themethod = 'W' || themethod = 'M' ){
var s=parent.pagebas.document;
s.open();
s.write('<html><head></head><body bgcolor="#009999"
text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">');
s.write('<div align="center"><TABLE align="center" BORDER="0"
CELLPADDING="0" CELLSPACING="0" WIDTH="520"><TR><TD
width="400" bgcolor="#000000">');
s.write('<div align="center"><font color="#FFFFFF" face="Arial,
Helvetica, sans-serif" size="-2">');
s.write('Now loading and playing .... <i>',thename,'</i> .....
</font>');
s.write('<embed src="',thesound,'" height="20" width="100" hidden
autoplay="true">');
s.write('</embed></div></TD></TR></TABLE></div></body></html>');
s.close();
}
else if (themethod = 'X' || themethod = 'N'){
var s=parent.pagebas.document;
s.open();
s.write('<html><head></head><body bgcolor="#009999"
text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">');
s.write('<div align="center"><TABLE align="center" BORDER="0"
CELLPADDING="0" CELLSPACING="0" WIDTH="520"><TR><TD
width="400" bgcolor="#000000">');
s.write('<div align="center"><font color="#FFFFFF" face="Arial,
Helvetica, sans-serif" size="-2">');
s.write('Now loading and playing .... <i>',thename,'</i> .....
</font>');
s.write('<SCRIPT LANGUAGE="JavaScript">
s.location.href="',thesound,'" </script>');
s.write('</div></TD></TR></TABLE></div></body></html>');
s.close();
}
}
</SCRIPT>
 
R

RobG

bunch92 said:
Hi,
I am stuck with ideas guys ....

Can someone please tell me what I did wrong in the code below ? I think
it might be the <script> tag inside the function ?

Thank you


<SCRIPT LANGUAGE="JavaScript">

Language is depreciated, type is required.

function playasound(thesound,thename,themethod)
{
if (themethod = 'W' || themethod = 'M' ){

Did you really mean assignment above or is evaluation required?

if (themethod == 'W' || themethod == 'M' ){

That is why it is often recommended to write comparisons with string
literals with the string on the left so that assignment will cause an
error rather than always be true:

if ( 'W' == themethod || 'M' == themethod ){

Otherwise the else statement will never be executed.

[...]
else if (themethod = 'X' || themethod = 'N'){

else if ( 'X' == themethod || 'N' == themethod ){

[...]
 
B

bunch92

Language is depreciated, type is required.
<script type="text/javascript">

[...]

if ( 'W' == themethod || 'M' == themethod ){


Thank you very much for this.
btw .. I meant evaluation, and will use your technique from now on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top