• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Communicating With Browser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Communicating With Browser


  • Subject: Communicating With Browser
  • From: Zack Morris <email@hidden>
  • Date: Sat, 6 Nov 2004 20:21:37 -0700

Hi, I am writing a utility that needs to send events back and forth between the browser and an app. Right now I can put a link in the browser like <a href="myApp://test">test</a> and when the user clicks on it, it opens my app, and I use the AEGetURL() code at the bottom of this email to bring up an alert with the URL "myApp://test". I would also like to open the browser from within my app, using LaunchURL( "\phttp://www.myurl.com/test.php"; ), a routine I have also put below.
But the problem is, if they have the URL already open in a window, this causes it to reload, at least in Safari. This is unacceptible, because they lose whatever info the have entered on the page. Is there any way to tell the browser not to reload the page if it is already open? Is there a way that perhaps I could check the current browser's window, and if the page is already open, just bring that app/process to the front? Could I put all of this into an apple event or applescript perhaps? I did notice that if I put a random string on the end like "http://www.myurl.com/test.php?junk=378456783456783478"; it opens the page in a new window every time, which is less destructive, but still a nuisance since the user has to close the new window. I wish I could just call something like LaunchURL( "\phttp://www.myurl.com/test.php";, kDoNotReloadIfOpen ), if such a thing existed. If I could construct the raw Apple event that InternetConfig uses, that would work too.


Thanx,

------------------------------------------------------------------------
Zack Morris              Z Sculpt Entertainment               This Space
email@hidden      http://www.zsculpt.com                 For Rent
------------------------------------------------------------------------
If the doors of perception were cleansed, everything would appear to man
  as it is, infinite. -William Blake, The Marriage of Heaven and Hell

//----- ROUTINES -----

pascal OSErr AEGetURL( const AppleEvent *messagein, AppleEvent *reply, long refIn )
{
#pragma unused( reply,refIn )

static char myURL[1100]; // static so we don't keep allocating it on the stack
AEDescList docList;
OSErr myErr;
long itemsInList, index;
Size actualSize;
AEKeyword keywd;
DescType returnedType;

// get the direct parameter--a descriptor list--and put it
myErr = AEGetParamDesc( messagein, keyDirectObject, typeAEList, &docList );

if( myErr )
{
ParamText( StrNum( myErr ) );
ErrorDialog( "\p(^0) AEGetParamDesc() failed." );
}
else
{
// count the number of descriptor records in the list
myErr = AECountItems( &docList, &itemsInList );

if( myErr ) ErrorDialog( "\pAECountItems() failed." );
else
{
// now get each descriptor record from the list,
// coerce the returned data to a c string
for( index = 0; index < itemsInList; index++ )
{
myErr = AEGetNthPtr( &docList, index+1, typeWildCard, &keywd,
&returnedType, &myURL, sizeof( myURL ), &actualSize );

if( !myErr ) AlertDialog( myURL );
}
}
}

return( noErr );
}


OSStatus LaunchURL( ConstStr255Param urlStr )
{
if( ICStart )
{
ICInstance inst;
OSStatus theErr;
long startSel;
long endSel;

theErr = ICStart( &inst, APPL.creatorCode );

if( theErr == noErr )
{
startSel = 0;
endSel = urlStr[0];
theErr = ICLaunchURL( inst, nil, (char *) &urlStr[1], urlStr[0], &startSel, &endSel );

ICStop( inst );
}

return( theErr );
}

return( icInternalErr );
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Communicating With Browser
      • From: Quinn <email@hidden>
References: 
 >Re: testing for firewall and modifying ports (From: Ryan McGann <email@hidden>)

  • Prev by Date: Re: testing for firewall and modifying ports
  • Next by Date: System Configuration Framework and PPTP (VPN) Connections
  • Previous by thread: Re: testing for firewall and modifying ports
  • Next by thread: Re: Communicating With Browser
  • Index(es):
    • Date
    • Thread