473,853 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.open() Not Opening in Same Window All The Time

Hi All,

I'm having a problem that is driving me absolutely batty and I'm hoping
that one of you JavaScript gurus can help me out before I go stark
raving mad.

I am using the function shown below to open links into the same pop-up
window each time a user clicks any of the news story links contained in
http://www.kris.ca/newsroom.aspx. The function works perfectly for all
of the links except for the ones from the BBC's website. Links to
stories from the BBC's website insist on opening in a new popup window
each time no matter what I do. This behaviour is consistent in both IE
and Firefox.

The behaviour makes absolutely no sense to me as all of the links use
the same function call. Any ideas?
function popupfeed(url) {
var myfeatures =
"toolbar=no,loc ation=no,direct ories=no,menuba r=yes,scrollbar s=yes,status=ye s,resizable=yes ,width=800,heig ht=600";

thefeed = window.open( url, 'feed2jspop', myfeatures);
if (window.focus) {thefeed.focus( )}
}

Apr 14 '06 #1
5 5402
k.************* @gmail.com wrote:
Hi All,

I'm having a problem that is driving me absolutely batty and I'm hoping
that one of you JavaScript gurus can help me out before I go stark
raving mad.

I am using the function shown below to open links into the same pop-up
window each time a user clicks any of the news story links contained in
http://www.kris.ca/newsroom.aspx. The function works perfectly for all
of the links except for the ones from the BBC's website. Links to
stories from the BBC's website insist on opening in a new popup window
each time no matter what I do. This behaviour is consistent in both IE
and Firefox.


You say this works fine on all other links? That would lead me to
suspect the BBC site instead - perhaps they have some sort of code that
opens the new popup?
Apr 14 '06 #2
Thank you for the response Tony. That thought had occurred to me as
well but wouldn't that cause two pop-ups then - one from my code and
another from theirs?

Apr 15 '06 #3
k.************* @gmail.com wrote:
Hi All,

I'm having a problem that is driving me absolutely batty and I'm hoping
that one of you JavaScript gurus can help me out before I go stark
raving mad.

I am using the function shown below to open links into the same pop-up
window each time a user clicks any of the news story links contained in
http://www.kris.ca/newsroom.aspx. The function works perfectly for all
of the links except for the ones from the BBC's website. Links to
stories from the BBC's website insist on opening in a new popup window
each time no matter what I do. This behaviour is consistent in both IE
and Firefox.

The behaviour makes absolutely no sense to me as all of the links use
the same function call. Any ideas?
function popupfeed(url) {
var myfeatures =
"toolbar=no,loc ation=no,direct ories=no,menuba r=yes,scrollbar s=yes,status=ye s,resizable=yes ,width=800,heig ht=600";

thefeed = window.open( url, 'feed2jspop', myfeatures);
if (window.focus) {thefeed.focus( )}
}


Try instead:

// Declare window name as a global variable
var feedWindow;

function popupfeed(url)
{

// Open window only if not already open
if (!feedWindow || feedWindow.clos ed){

// Just include the features you want, the others will be
// off by default (if permitted by browser settings)
var popfeatures =
"menubar,scroll bars,status,res izable,width=80 0,height=600";

feedWindow = window.open('', 'feed2jspop','p opfeatures');
}

// Set the location
feedWindow.loca tion = url;

// Give it focus
if (feedWindow.foc us) feedWindow.focu s();

// Allow onclick to stop navigation if A element used
return !feedWindow;
}
Read the stuff here:

<URL:http://developer.mozil la.org/en/docs/DOM:window.open >

--
Rob
Apr 15 '06 #4
Thank you for the response RobG. Your solution worked like a charm
except that I couldn't I couldn't get the scroll bars to appear ...
which presents a problem if the news story doesn't fit in the 800 x 600
window. Any ideas?

Apr 18 '06 #5
Please disregard my previous reply ... I got the scroll bars working
now ... stupid typo on my part. :)

The solution is working 99% of the time now but it still opens new
windows occasionally. It's very bizarre, but it seems that a new window
is opened each time you transition from the BBC's news stories to news
stories from any other source. For example, if I display stories from
the BBC, I can click to my hearts content and the stories will stay in
the same pop-up. If, however, the pop-up is open and it contains a
story from the BBC and I try to display a story from any other source
(ABC News for example), the story will open a brand new pop-up. Very
odd to say the least!

Is it possible that the BBC's page contains some javascript that
detects when the window is navigating to a different domain? If so, is
there anyway that I can disable javascript for the link that I am
opening?

Apr 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
9473
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to intercept the key so that I can do stuff on the server side to make the new window behave correctly? (We have a JSP-based webapp which stores state in the session. Now if two windows access (and modify!) the same session, then madness will result....
10
11257
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but is, and I have tested it with both version 4.72 and 7.02, and they both do it. IE does not do it....
10
6768
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a new window with maximized dimensions!) FYI, I uploaded the same code to: http://tosasoft.com/test/open.htm ========================================
17
2522
by: Applebrownbetty | last post by:
Hi, I'd like to append/amend the following code from the Dreamweaver extension "Open Picture Window Fever" for the ability to center the PopUp window: By default, it allows the window to be offset on the left and top, but does not include a centering option. I'm thinking it would include something like (screen.width-imageWidth)/2; somewhere but not sure how do go about doing this.
14
11110
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
18
2522
by: Roger Withnell | last post by:
I open a new window from the current window to display maps. Several maps of different sizes can be displayed. The function is given the size of the map and adjusts the window size accordingly. If a new window is already open, the new map sizes are ignored and the new map is is either too small for the existing "new" window or too big, which is a more serious problem! I've tried to fix this by closing the new window if it is already...
4
3273
by: arajunk | last post by:
In Firefox this opens a full size window (maximized) . In IE it opens the partial window requiring user to click restore (upper right) to maximize. What am I missing ? var infoWindow=window.open('usgsMain.html','USGSwindow','status=no,resizable=yes,scrollbars=yes');
3
10262
by: Andrew Poulos | last post by:
There's a HTA application that's running on a local computer (not from a URL) and the user can open a new HTML window by clicking a button The first time the user clicks the button the window opens. Any subsequent click causes this dialog, with this error, to appear: "Error: The remote server machine does not exist or is unavailable" The relevant code is
6
2074
by: SAL | last post by:
Hi, VS2005 post I'm opening a window using the following syntax: Protected Sub lbEstValue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Response.Write("<script>window.open('EstValueHelp.aspx','_help', 'width=400,height=400');</script>") End Sub
0
9898
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11020
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10358
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5934
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4143
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.