Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   use <script> inside function ? (http://www.velocityreviews.com/forums/t919492-use-script-inside-function.html)

bunch92 08-02-2005 12:47 PM

use <script> inside function ?
 
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>

bunch92 08-02-2005 01:06 PM

Re: use <script> inside function ?
 
bunch92 <bunch92@yahoo.fr> wrote in
news:Xns96A68A2F315F7bunch92yahoofr@213.123.26.234 :

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


Got it ...
I needed <\/script>

RobG 08-02-2005 01:47 PM

Re: use <script> inside function ?
 
bunch92 wrote:
> 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.

<script type="text/javascript">

> 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 ){

[...]

--
Rob

bunch92 08-02-2005 03:57 PM

Re: use <script> inside function ?
 
RobG <rgqld@iinet.net.auau> wrote in news:42ef797f$0$11941$5a62ac22@per-
qv1-newsreader-01.iinet.net.au:

> 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.

Douglas Crockford 08-02-2005 09:51 PM

Re: use <script> inside function ?
 
> Got it ...
> I needed <\/script>


JSLint catches problems like that.

http://www.JSLint.com


All times are GMT. The time now is 05:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.