|
 |
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
|
|
05-02-2007, 11:48 AM
|
PM User |
#1
|
|
New to the CF scene
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
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
|
|
|
|
05-02-2007, 03:27 PM
|
PM User |
#2
|
|
Supreme Master coder!

Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
|
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.
|
|
|
 |
Jump To Top of Thread
| Thread Tools |
|
|
| 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
HTML code is Off
|
|
|
All times are GMT +1. The time now is 01:56 AM.
|
Advertisement Log in to turn off these ads. |
|
|
|
|
|
|
|
|
|
|