From 6187aef7f723c35fa3a5fb5be5fac8887ed3c7ae Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Thu, 2 Nov 2000 08:43:19 +0000 Subject: [PATCH] Fixing bug 25821. This is only a bandaid for the real problem with targetting javascript: URL's but it fixes the immediate problem while the targetting code is being rewritten. r=brendan, sr=mscott --- docshell/base/nsDocShell.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 7834af72304f..a541127d8a12 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3306,8 +3306,35 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, // open a channel for the url nsCOMPtr channel; nsresult rv; + + nsCOMPtr ifreq; + + // This is a workaround to get javascript: URL's with a target + // attribute execute in the correct window, this only works if the + // target window exists when the link is clicked. + if (aWindowTarget && *aWindowTarget) { + nsXPIDLCString urlScheme; + aURI->GetScheme(getter_Copies(urlScheme)); + // do it only for javascript urls! + if (urlScheme && !nsCRT::strcasecmp(jsSchemeName, urlScheme)) { + nsAutoString targetName; targetName.AssignWithConversion(aWindowTarget); + + nsCOMPtr targetDocShell; + + FindItemWithName(targetName.GetUnicode(), + NS_STATIC_CAST(nsIInterfaceRequestor*, this), + getter_AddRefs(targetDocShell)); + + ifreq = do_QueryInterface(targetDocShell); + } + } + // End of workaround. + + if (!ifreq) + ifreq = NS_STATIC_CAST(nsIInterfaceRequestor*, this); + rv = NS_OpenURI(getter_AddRefs(channel), aURI, nsnull, loadGroup, - NS_STATIC_CAST(nsIInterfaceRequestor*, this)); + ifreq); if(NS_FAILED(rv)) { if(NS_ERROR_DOM_RETVAL_UNDEFINED == rv) // if causing the channel changed the