Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > use <script> inside function ?

Reply
Thread Tools

use <script> inside function ?

 
 
bunch92
Guest
Posts: n/a
 
      08-02-2005
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>
 
Reply With Quote
 
 
 
 
bunch92
Guest
Posts: n/a
 
      08-02-2005
bunch92 <(E-Mail Removed)> wrote in
news:Xns96A68A2F315F7bunch92yahoofr@213.123.26.234 :

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


Got it ...
I needed <\/script>
 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      08-02-2005
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
 
Reply With Quote
 
bunch92
Guest
Posts: n/a
 
      08-02-2005
RobG <(E-Mail Removed)> 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.
 
Reply With Quote
 
Douglas Crockford
Guest
Posts: n/a
 
      08-02-2005
> Got it ...
> I needed <\/script>


JSLint catches problems like that.

http://www.JSLint.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining a function inside a function. Whats this feature ? How touse inside a class ? Sur Ruby 4 01-08-2008 02:50 PM
Confusion over calling a nested function inside a parent function Pyenos Python 5 12-23-2006 01:46 PM
member function definition inside and outside class..function already defined error.. ypjofficial@indiatimes.com C++ 1 01-09-2006 09:49 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Re: Can We Use EXEC CGI Inside a JavaScript Applet Inside an HTML File? David Dorward HTML 1 06-28-2003 09:30 AM



Advertisments