From 56638dd56edff9723b183c0ede01ecb5d5985b5f Mon Sep 17 00:00:00 2001 From: "jaggernaut%netscape.com" Date: Thu, 11 Apr 2002 01:20:02 +0000 Subject: [PATCH] Bug 37638: URL bar is given focus by default in new window [via accel+N or File > New Navigator Window] Bug 89835: Window opened up with JavaScript has focus in the URL bar while NN4 and IE put focus on the content area Focus will now always go to the content area unless we're opening for a blank page. r=bryner, sr=hewitt --- xpfe/browser/resources/content/navigator.js | 13 ++++---- .../resources/content/contentAreaUtils.js | 33 +++++++------------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 3f1890262f7..d3a9f5e879c 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -410,8 +410,8 @@ function Startup() if (uriToLoad && uriToLoad != "about:blank") { gURLBar.value = uriToLoad; - if ("arguments" in window && window.arguments.length >= 4) { - loadURI(uriToLoad, window.arguments[3]); + if ("arguments" in window && window.arguments.length >= 3) { + loadURI(uriToLoad, window.arguments[2]); } else { loadURI(uriToLoad); } @@ -428,12 +428,11 @@ function Startup() return; } - // Focus the content area if the caller instructed us to. - if ("arguments" in window && window.arguments.length >= 3 && window.arguments[2] == true || - !window.locationbar.visible) - setTimeout(WindowFocusTimerCallback, 0, _content); - else + // Focus the content area unless we're loading a blank page + if (uriToLoad == "about:blank" && window.locationbar.visible) setTimeout(WindowFocusTimerCallback, 0, gURLBar); + else + setTimeout(WindowFocusTimerCallback, 0, _content); // Perform default browser checking (after window opens). setTimeout( checkForDefaultBrowser, 0 ); diff --git a/xpfe/communicator/resources/content/contentAreaUtils.js b/xpfe/communicator/resources/content/contentAreaUtils.js index 2609fd456fb..31f1df5f701 100644 --- a/xpfe/communicator/resources/content/contentAreaUtils.js +++ b/xpfe/communicator/resources/content/contentAreaUtils.js @@ -84,38 +84,29 @@ function getReferrer(doc) function openNewWindowWith(url) { urlSecurityCheck(url, document); - var newWin; - var wintype = document.firstChild.getAttribute('windowtype'); - var referrer = getReferrer(document); // if and only if the current window is a browser window and it has a document with a character // set, then extract the current charset menu setting from the current document and use it to // initialize the new browser window... - if (window && (wintype == "navigator:browser") && - window._content && window._content.document) { - var DocCharset = window._content.document.characterSet; - var charsetArg = "charset="+DocCharset; + var charsetArg = null; + var wintype = document.firstChild.getAttribute('windowtype'); + if (wintype == "navigator:browser") + charsetArg = "charset=" + window._content.document.characterSet; - //we should "inherit" the charset menu setting in a new window - newWin = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url, charsetArg, true, referrer ); - } - else { // forget about the charset information. - newWin = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url, null, true, referrer ); - } + var referrer = getReferrer(document); + window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url, charsetArg, referrer); } function openNewTabWith(url) { urlSecurityCheck(url, document); - var wintype = document.firstChild.getAttribute('windowtype'); - var referrer = getReferrer(document); + var browser = getBrowser(); - if (window && (wintype == "navigator:browser")) { - var browser = getBrowser(); - var t = browser.addTab(url, referrer); // open link in new tab - if (pref && !pref.getBoolPref("browser.tabs.loadInBackground")) - browser.selectedTab = t; - } + var referrer = getReferrer(document); + var tab = browser.addTab(url, referrer); // open link in new tab + + if (pref && !pref.getBoolPref("browser.tabs.loadInBackground")) + browser.selectedTab = tab; } function findParentNode(node, parentNode)