Jonathan Gilpin
Posts: 50
Joined: 2012-12-11
|
Hi Guys,
Any thoughts on how to get the query string parameters of a url loaded in a new window/process?
Here is the flow of my IE Addon:
1.)Open IE for the first time and the first ADXIEModule instance is instantiated/loaded.
2.)The first ADXIEModule instance will call IEApp.Navigate(newUrlWithQueryStringParams, ref flags, target); //where object flags = null; object target = "_blank";
3.)Now a new tab opens, which instantiates a second ADXIEModule instance.
From the *second* ADXIEModule instance, how can I know the query string parameters?
BeforeNavigate2 event does not fire in the second instance..but only the first instance.
I'm looking for a way to identify from the second instance, that it was the one opened by original Navigate call.
Any thoughts on how to do this? |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Jonathan,
Please try the code below:
private string targetURL = String.Empty;
public string GetTargetURL()
{
string _temp = this.targetURL;
this.targetURL = String.Empty;
return _temp;
}
private void adxieContextMenuCommandItem2_OnClick(object sender, object htmlElement)
{
object flags = null; object target = "_blank";
this.targetURL = "//www.add-in-express.com/forum/read.php?FID=10&TID=11737&MID=59783#message59783";
IEApp.Navigate("about:blank?threadID=" + this.ThreadID.ToString() + "&processID=" + this.ProcessID.ToString(), ref flags, target);
}
private void IEModule_DocumentComplete(object pDisp, string url)
{
if (!String.IsNullOrEmpty(url))
{
if (url.StartsWith("about:blank?threadID=", StringComparison.InvariantCultureIgnoreCase))
{
int tabThreadID = 0;
int tabProcessID = 0;
try
{
string callerIDs = url.Replace("about:blank?", String.Empty);
string[] parts = callerIDs.Split('&');
tabThreadID = int.Parse(parts[0].Replace("threadID=", String.Empty));
tabProcessID = int.Parse(parts[1].Replace("processID=", String.Empty));
}
catch (Exception)
{
}
if (tabThreadID != 0 && tabProcessID != 0)
{
string newUrlWithQueryStringParams = String.Empty;
ArrayList modules = ADXIEModule.GetModulesByTypeName(this.GetType().FullName);
foreach (ADXIEModule m in modules)
{
if (m.ThreadID == tabThreadID && m.ProcessID == tabProcessID)
{
newUrlWithQueryStringParams = ((IEModule)m).GetTargetURL();
break;
}
}
if (!String.IsNullOrEmpty(url))
{
object flags = null; object target = "_self";
IEApp.Navigate(newUrlWithQueryStringParams, ref flags, target);
}
}
}
}
}
|
|
Jonathan Gilpin
Posts: 50
Joined: 2012-12-11
|
Thanks Sergey, I'll give it a shot! |
|
Jonathan Gilpin
Posts: 50
Joined: 2012-12-11
|
Seems to be a typo:
this.targetURL = ";;
is that meant to be this.targetURL = ";;" ? or this.targetURL = ""; ? |
|
Jonathan Gilpin
Posts: 50
Joined: 2012-12-11
|
Thanks Sergey, this will work perfectly!
The reason DocumentComplete never fired on the newly opened form, was because of the redirect that page is doing. Opening to about:blank first allows the load to finish..thereby firing DocumentComplete, which has all the query string parameters.
Thank you so much!
Jon |
|