Click to See Complete Forum and Search --> : setFocus


kirk.netiq
04-13-2004, 11:45 AM
I am publishing an Authorware piece for web delivery. In this piece I have a text entry field where the user enters some information. The problem is that the current focus is on the browser NOT the embedded Authorware piece. So the user has to click in the browser to be able to enter information into the text feild in the published piece.

My question is - how can I setFocus to the Authroware piece. Each time I publish, a piece will have a different name and is done using document.write

Any help would be greatly appreciated.


Here is the code:
<html>
<head>
<title>Expense Report</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body bgcolor="#555555"onLoad="setFocus()">
<center>
<script language="VBScript">
Function IsAuthorwareControl()
on error resume next
MM_AWARE = False
MM_AWARE = IsObject(CreateObject("Macromedia.AuthorwareShockwaveControl.1"))
IsAuthorwareControl = MM_AWARE
End Function
</script>
<script language="JavaScript">
var MM_AWARE = false
for (i = 0; i < navigator.plugins.length; i++)
if (navigator.plugins[i].name.indexOf("Authorware") != -1)
MM_AWARE = parseFloat(navigator.plugins[i].description.substring(navigator.plugins[i].description.indexOf("version ") + 8)) >= 7;
if (!MM_AWARE && navigator.appName != "Netscape") MM_AWARE = IsAuthorwareControl()
if (MM_AWARE) {
document.write('<object classid="CLSID:15B782AF-55D8-11D1-B477-006097098764" codebase="http://intra.netiq.com/it_training/Authorware 7 Compact Web Player installers/ActiveX Cab/cabload.htm" width="802" height="564">\n');
document.write(' <param name="SRC" value="exreport.aam">\n');
document.write(' <param name="PALETTE" value="background">\n');
document.write(' <param name="WINDOW" value="inPlace">\n');
document.write(' <param name="BGCOLOR" value="#555555">\n');
document.write(' <embed src="exreport.aam" palette="background" window="inPlace" bgcolor="#555555" pluginspage="http://intra.netiq.com/it_training/Authorware 7 Compact Web Player installers/ActiveX Cab/cabload.htm" type="application/x-authorware-map" width="802" height="564">\n');
document.write(' </embed>\n');
document.write('</object>');
} else
document.write('You do not have the Authorware 7 Web Player installed. Please go to back to the start page and read the Web Player installation instructions.');
</script>
</body>
</html>

neil9999
04-13-2004, 11:51 AM
Try reffering the object, and add .focus() on the end, like:

document.getElementById("objectthingy").focus()

Neil

kirk.netiq
04-13-2004, 12:05 PM
Thank you for your reply...

In the example you gave:

document.getElementById("objectthingy").focus()


how would I reference "objectthingy" when it is a document write object and the name of the Authorware piece is always different? (I guess I could always call it the asme name..but that might get confusing).

Thanks

Kirk

crh3675
04-13-2004, 12:08 PM
Give the OBJECT tag an ID and use that ID


document.write('<object id="authorwareObject" classid="CLSID:15B782AF-55D8-11D1-B477-006097098764" codebase="http://intra.netiq.com/it_training/Authorware 7 Compact Web Player installers/ActiveX Cab/cabload.htm" width="802" height="564">\n');


Then before your closting script tag:


document.getElementById("authorwareObject").focus()
</script>

kirk.netiq
04-13-2004, 12:32 PM
Would that go in the head section or the body?

crh3675
04-13-2004, 12:38 PM
Just use this code:


<html>
<head>
<title>Expense Report</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body bgcolor="#555555"onLoad="setFocus()">
<center>
<script language="VBScript">
Function IsAuthorwareControl()
on error resume next
MM_AWARE = False
MM_AWARE = IsObject(CreateObject("Macromedia.AuthorwareShockwaveControl.1"))
IsAuthorwareControl = MM_AWARE
End Function
</script>
<script language="JavaScript">
var MM_AWARE = false
for (i = 0; i < navigator.plugins.length; i++)
if (navigator.plugins[i].name.indexOf("Authorware") != -1)
MM_AWARE = parseFloat(navigator.plugins[i].description.substring(navigator.plugins[i].description.indexOf("version ") + 8)) >= 7;
if (!MM_AWARE && navigator.appName != "Netscape") MM_AWARE = IsAuthorwareControl()
if (MM_AWARE) {
document.write('<object id="authorwareObject" classid="CLSID:15B782AF-55D8-11D1-B477-006097098764" codebase="http://intra.netiq.com/it_training/Authorware 7 Compact Web Player installers/ActiveX Cab/cabload.htm" width="802" height="564">\n');
document.write(' <param name="SRC" value="exreport.aam">\n');
document.write(' <param name="PALETTE" value="background">\n');
document.write(' <param name="WINDOW" value="inPlace">\n');
document.write(' <param name="BGCOLOR" value="#555555">\n');
document.write(' <embed src="exreport.aam" palette="background" window="inPlace" bgcolor="#555555" pluginspage="http://intra.netiq.com/it_training/Authorware 7 Compact Web Player installers/ActiveX Cab/cabload.htm" type="application/x-authorware-map" width="802" height="564">\n');
document.write(' </embed>\n');
document.write('</object>');
} else{
document.write('You do not have the Authorware 7 Web Player installed. Please go to back to the start page and read the Web Player installation instructions.');
}

document.getElementById("authorwareObject").focus();

</script>
</body>
</html>

kirk.netiq
04-13-2004, 01:20 PM
First off,

Thanks for your time..it is greatly appreciated.

I put your code in..it still does not change the focus to the text box in the Authorware piece until the user clicks on the embedded piece, (This is for IE browsers. fyi...). Any thoughts? I though of using onKeypress....

:)

crh3675
04-13-2004, 02:01 PM
This is kind of a kludge but you can VBScript a key event in the onload handlerr:



<script type="text/vbscript">

Function InitLoad()
SendKeys(Chr(9))
End Function

</script>


Which will send a TAB key. Not sure what else to do

kirk.netiq
04-13-2004, 02:35 PM
Craig,

Thank you very much for all the help!