 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
yotafan
Joined: 28 Oct 2004 Posts: 10
|
Posted: Thu Oct 28, 2004 1:14 pm To call a key press for a button |
|
|
|
IF someones code calls for a user to interact with a popup to hit yes or no.
Is there a way that i can add a line into the code so it automatically calls the Y keypress, so it assumes that the user hit the yes button. |
|
nagasree
Joined: 21 Sep 2004 Posts: 81 Location: Hyderabad, India
|
Posted: Fri Oct 29, 2004 12:12 am |
|
|
|
Try this one out
| Code: |
<script language="javascript">
var isNetscape = false;
if (navigator.appName == "Netscape"){
isNetscape = true;
document.captureEvents(Event.KEYPRESS);
}
document.onkeypress=CheckKeyPress;
function CheckKeyPress(evt){
var myKeycode = isNetscape ? evt.which : window.event.keyCode;
if(myKeycode==121 || myKeycode==89) YesClicked();
if(myKeycode==110 || myKeycode==78) NoClicked();
}
function YesClicked(){alert("Yes is Clicked")}
function NoClicked(){alert("No is Clicked")}
</script>
<FORM name="frmSample">
<input type=button name="btnYes" onclick="javascript:YesClicked();" value=" Yes ">
<input type=button name="btnNo" onclick="javascript:NoClicked();" value=" No ">
</FORM>
|
-Nagasree |
|
yotafan
Joined: 28 Oct 2004 Posts: 10
|
Posted: Fri Oct 29, 2004 10:41 am Key Press |
|
|
|
I tried inserting that but it didn't work.
Here is the code. I would like for it to force the yes button so there is no user intereaction.
<HTML>
<!--
Copyright (c) 2000 Microsoft Corporation
-->
<HEAD>
<meta http-equiv="MSThemeCompatible" content="Yes">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Remote Assistance</TITLE>
<LINK id="UI_StyleSheet" REL="stylesheet" TYPE="text/css" HREF="../../Css/rc.css">
<LINK id="UI_StyleSheet1" REL="stylesheet" TYPE="text/css" HREF="hcp://system/css/shared.css">
<SCRIPT Language="JavaScript">
g_bDebug = false;
var L_ERRACCESSDENIED_Text = "Directly launching this page is not allowed. ";
function InitiateMsg()
{
var vArgs = window.dialogArguments;
try
{
idExpert1.innerText = vArgs[0];
idExpert2.innerText = vArgs[0];
idExpert3.innerText = vArgs[0];
}
catch(error)
{
idBody.style.visibility = "hidden";
alert( L_ERRACCESSDENIED_Text );
return;
}
return;
}
function onClickHandler( id )
{
window.returnValue = id;
window.close();
}
</SCRIPT>
<Style>
.height14
{
height:5px;
}
</Style>
</HEAD>
<BODY id="idBody" class="sys-inlineform-bgcolor1" onload=InitiateMsg()>
<Table name="idMainTable" id="idMainTable" class="MaxLayout" cellpadding="0" cellspacing="0" border=0>
<TR>
<TD class="padding6 padding4 padding3">
<table id="idMsgTbl" name="idMsgTbl" cellspacing=0 cellpadding=0 class="MaxLayout" border=0>
<tr id="TR0" name="TR0">
<td id="MessageId" colspan=2 name="MessageId" class="sys-font-body sys-color-body padding5 padding2 padding8">
<Span id="idExpert1" name="idExpert1">Your Helper</Span> would like to share control of your computer to help solve the problem.
</td>
</tr>
<TR>
<TD class="height5" colspan=2>
</TD>
</TR>
<TR>
<td id="idTD2" name="idTD2" class="sys-font-body sys-color-body padding5 padding2" colspan=2>
Do you wish to let <Span id="idExpert2" name="idExpert2">Your Helper </Span> share control of your computer?
</td>
</tr>
<TR>
<TD class="height13" colspan=2>
</TD>
</TR>
<tr id="TR2" name="TR2">
<td id="idbtnrow" name="idbtnrow" align=right colspan=2 class="padding2">
<button class="styBtnWidth sys-font-body sys-color-body" onClick="onClickHandler(0)" id="button0" name="button0" tabindex=2 accesskey="Y"><U>Y</U>es</button>
<Span id="idblankSpace" name="idblankSpace" class="width8"></Span>
<button class="styBtnWidth sys-font-body sys-color-body" onClick="onClickHandler(1)" id="button1" name="button1" tabindex=1 accesskey="N"><U>N</U>o</button>
</td>
</tr>
<TR id="TR3" name="TR3">
<td id="TD0TR3" name="TD0TR3" colspan=2 class="padding5 padding2">
<HR>
</td>
</TR>
<tr>
<td class="height14" colspan=2>
</TD>
</tr>
<TR id="TR5" name="TR5">
<td id="TD0TR5" name="TD0TR5" class="padding5 padding7">
<IMG id="idimg" name="idimg" class="Maxheight" src="ESC_key.gif">
</td>
<td id="TD2TR5" name="TD2TR5" class="sys-font-body sys-color-body padding2 padding6">
It is recommended that you and <Span id="idExpert3" name="idExpert3"> your helper </Span> do not use the
mouse at the same time. You can monitor all activity and stop control at any time by pressing the ESC key. Note that
using any key sequence or combination including the ESC key will also stop control.
</td>
</tr>
</Table>
</TD>
</TR>
</Table>
</BODY>
</HTML> |
|
nagasree
Joined: 21 Sep 2004 Posts: 81 Location: Hyderabad, India
|
Posted: Sat Oct 30, 2004 5:43 am |
|
|
|
Include this before closing the body tag.
The event click will be invoked automatically, five seconds from the page is rendered. you can alter the milli seconds for invoking the same as required. Hope this is what u want
| Code: |
<script language="javascript">
//give no of seconds you want to show popup before invoking
//the Yes click automatically - 5 * 1000 = 5000ms
setTimeout("onClickHandler(0)",5000);
</script>
|
-Nagasree |
|
yotafan
Joined: 28 Oct 2004 Posts: 10
|
Posted: Tue Nov 02, 2004 9:20 pm Thank You |
|
|
|
Nagasree, Thanks
IT works perfectly now. |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|