Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-02-2007, 11:48 AM   PM User | #1
clivemcl
New to the CF scene

 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
clivemcl is an unknown quantity at this point
Nested Javascript problem

I have a Javascript which select a function at random.
There are two functions, each function selects a different flash movie.

I call my flash movies with a seperate Javascript which removes the ActiveX crap, called AC_FL_RunContent.

This is how it looks...



<script language="JavaScript">

// Generate a Random Number
var randomnumber = Math.round(Math.random()*2);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else {movie2();}

//Functions to write out the correct flash movie resource.

function movie1(){
document.write("
<script type=\"text/javascript\" >
AC_FL_RunContent(\"codebase\",\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\",\"width\",\"180\",\"height\",\"599\",\"src\",\"images/sideguitar\",\"quality\",\"high\",\"name\",\"images/sideguitar\",\"allowscriptaccess\",\"sameDomain\",\"pluginspage\",\"http://www.macromedia.com/go/getflashplayer\",\"movie\",\"images/sideguitar\" );
</script>
")
}



function movie2(){
document.write("
<script type=\"text/javascript\" >
AC_FL_RunContent(\"codebase\",\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\",\"width\",\"180\",\"height\",\"599\",\"src\",\"images/sidefountains\",\"quality\",\"high\",\"name\",\"images/sidefountains\",\"allowscriptaccess\",\"sameDomain\",\"pluginspage\",\"http://www.macromedia.com/go/getflashplayer\",\"movie\",\"images/sideguitar\" );
</script>
")
}


</script>


the problem (i think) is that the </script> of the inner Javascript is closing the outer one.
The output web page gives me text beginning


") } function movie2(){ document.write(" ") }

and no flash
clivemcl is offline   Reply With Quote
Old 05-02-2007, 03:27 PM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Remove the script tag inside the document.write statement.
Code:
function movie1(){
   document.write(AC_FL_RunContent("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0", "width", "180", "height", "599", "src", "images/sideguitar", "quality", "high", "name", "images/sideguitar", "allowscriptaccess", "sameDomain", "pluginspage", "http://www.macromedia.com/go/getflashplayer", "movie", "images/sideguitar"));
}
This assumes that AC_FL_RunContent function returns the object html tags to write to the page.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:56 AM.


Advertisement
Log in to turn off these ads.