473,395 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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,location=no,directories=no,menubar=yes ,scrollbars=yes,status=yes,resizable=yes,width=800 ,height=600";

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

Apr 14 '06 #1
5 5378
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,location=no,directories=no,menubar=yes ,scrollbars=yes,status=yes,resizable=yes,width=800 ,height=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.closed){

// Just include the features you want, the others will be
// off by default (if permitted by browser settings)
var popfeatures =
"menubar,scrollbars,status,resizable,width=800,hei ght=600";

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

// Set the location
feedWindow.location = url;

// Give it focus
if (feedWindow.focus) feedWindow.focus();

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

<URL:http://developer.mozilla.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
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...
10
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="#"...
10
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...
17
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...
14
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...
18
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....
4
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...
3
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...
6
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)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.