PDA

Click to See Complete Forum and Search --> : talking to javascript via FSCOMMAND



blanius
01-30-2002, 05:42 PM
Robert said that I could send javascript commands via FSCOMMAND but I can't seem to get it working.
this is what I've got for the javascript

<script language="Javascript">
<!--

function testjs_DoFSCommand (command, args)
{
document.write("Test");
if (command=="gosite") {
newWindow = window.open("dobi.html","Dobiecki","height=400,width=480");
}
}


//-->
</script>


In the Movie I have the action of a button as
FSCOMMAND gosite input

Any ideas?

erikpm
01-31-2002, 12:10 AM
I got it to work yesterday with these 3 additions but I am not sure if all three are needed. I borrow the code from another web page using flash.

1) Added the var testjsObj line after the function statement:

function testjs_DoFSCommand(command, args)
{
var testjsObj = InternetExplorer ? testjs : document.testjs;

2) Added this code for Internet Explorer within the <SCRIPT> tag:

// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('Sub testjs_FSCommand(ByVal command, ByVal args)\n');
document.write(' call testjs_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</SCRIPT\> \n');

3) I made sure that the <OBJECT> tag had this in it:

id=testjs

Works great for me but I am too green to know if all three had to be used.

blanius
01-31-2002, 11:31 PM
Originally posted by erikpm
I got it to work yesterday with these 3 additions but I am not sure if all three are needed. I borrow the code from another web page using flash.

1) Added the var testjsObj line after the function statement:

function testjs_DoFSCommand(command, args)
{
var testjsObj = InternetExplorer ? testjs : document.testjs;

2) Added this code for Internet Explorer within the <SCRIPT> tag:

// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('Sub testjs_FSCommand(ByVal command, ByVal args)\n');
document.write(' call testjs_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</SCRIPT\> \n');

3) I made sure that the <OBJECT> tag had this in it:

id=testjs

Works great for me but I am too green to know if all three had to be used.

Well I can tell you that 1 is not needed, but it's interesting that this worked for you. Part of my problem is that I'm in the process of moving and my books are packed So I can't readily look up javascript stuff.

2 is simply writing the same thing in Vbscript to the document if Explorer is detected. Not what I want to do, and interestingly I tried using this to see and it did partly work but then crashed my browser, I'll have to look at it some more.

blanius
01-31-2002, 11:53 PM
My function is fine I've determined this by calling it manually via javascript in the page, however I cannot seem to get my flash program to call the function, so that is where my problems lie, I'm thinking it's the name thing, and that the html produced via 3dfa is not adding the needed tag so that javascript knows the name of the movie.

ajcompany
02-02-2002, 10:28 AM
3dfa might not be inserting the id=testjs in the object tag, especially if the name inside the movie (not the save title) is not testjs.