Link to home
Start Free TrialLog in
Avatar of AndyBarrow
AndyBarrow

asked on

Error 47 Permission Denied in IE6

Hi

Using Delphi 2005 Pro /  Intraweb 7.2 / IE version 6.0.2900.2180 / XP Home SP2

I need to have a button on an Intraweb form that simply brings up the browser search window (i.e. emulates the CTRL-F keystrokes).  The following code brings the window up fine but when I try to execute the search I get "Error 47 Permission Denied".  I don't get the error when I just hit CTRL-F.  I presume this is some IE automation security protection but is there a work around?

  keybd_event(VK_CONTROL, 0, 0, 0);
  keybd_event(70, 0, 0, 0);
  keybd_event(70, 0, KEYEVENTF_KEYUP, 0);
  keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);

Many Thanks

ASKER CERTIFIED SOLUTION
Avatar of BlackTigerX
BlackTigerX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AndyBarrow
AndyBarrow

ASKER

Yup makes sense.  Don't think Javascript will allow key emulation though for security reasons.
Hi

Apologies for delay.  Haven't managed to find any JS to do this because of the obvious security implications of key emulation but find it hard to beleive that a browsers search function cannot be invoked somehow!?  I will award points 'cos strictly speaking you answered my question (even though with hindsight it was a bit of a dumb one  : )

regards
Andy.
you can use something like this:

http://www.javascripter.net/faq/searchin.htm

<form name="f1" action=""
onSubmit="if(this.t1.value!=null && this.t1.value!='')
findString(this.t1.value);return false"
>
<input type="text" name=t1 value="" size=20>
<input type="submit" name=b1 value="Find">
</form>

<script language="JavaScript">
<!--
var TRange=null

function findString (str) {
 if (parseInt(navigator.appVersion)<4) return;
 var strFound;
 if (navigator.appName=="Netscape") {

  // NAVIGATOR-SPECIFIC CODE

  strFound=self.find(str);
  if (!strFound) {
   strFound=self.find(str,0,1)
   while (self.find(str,0,1)) continue
  }
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {

  // EXPLORER-SPECIFIC CODE

  if (TRange!=null) {
   TRange.collapse(false)
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
  if (TRange==null || strFound==0) {
   TRange=self.document.body.createTextRange()
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
 }
 if (!strFound) alert ("String '"+str+"' not found!")
}
//-->
</script>
Many thanks for that.  I'll give that a go asap.