Solved

windows.open keeps opening new copies of named window

Posted on 2014-11-19
5
61 Views
Last Modified: 2014-11-28
Hi all,

I have some simple JavaScript that opens a webpage in a new window.

The issue is then every time the link is pressed, a new copy of the window is opened.

The following is the code I use:

window.open('MyPage.htm','UniqueWindow','scrollbars=yes');

Open in new window


Any help is greatly appreciated.

Thanks.

resourcesys
0
Comment
Question by:resourcesys
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 40453424
just make sure the target name is the same and it'll open up in the same window every time:

window.open(url, targetName);

you could also try using the _self attribute:

var myWindow = window.open("", "_self");
0
 

Author Comment

by:resourcesys
ID: 40454585
Hi Big Monty,

Normally I would agree with you but it definately is not working.

First time I've ever seen this.

Thanks for the response though.

resourcesys.
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 40455429
is the page accessible to the public?

do you have any other code running before /after the window.open command? if so try taking it out
0
 

Accepted Solution

by:
resourcesys earned 0 total points
ID: 40461600
The must be some of script interfering with is so I used the following code as a solution:

        var MyPageOpen = null;
        
        function gotoMyPageOpen()
        {            
            var theLink = 'MyPage.htm'; 
            
            try
            {
                if(MyPageOpen !== null && MyPageOpen !== false && typeof MyPageOpen !== 'undefined' && MyPageOpen !== 0 && !MyPageOpen.Closed)
                {
                    MyPageOpen.location = theLink;
                
                    MyPageOpen.focus();
                    
                    if(MyPageOpen.location == '')
                    {
                        MyPageOpen = window.open(theLink , 'MyPageOpen', 'scrollbars=yes,resizable=yes,width=1050,height=600,left=50px,top=50px');
                    }
                }
                else
                {
                    MyPageOpen = window.open(theLink , 'MyPageOpen', 'scrollbars=yes,resizable=yes,width=1050,height=600,left=50px,top=50px');
			    }
			}
			catch(e)
			{
			    MyPageOpen = window.open(theLink , 'MyPageOpen', 'scrollbars=yes,resizable=yes,width=1050,height=600,left=50px,top=50px');
			}
			finally
			{
			    var doNothing = true;
			}
        }

Open in new window


resourcesys
0
 

Author Closing Comment

by:resourcesys
ID: 40470206
No other solution provided. Own solution does work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now