?
Solved

windows.open keeps opening new copies of named window

Posted on 2014-11-19
5
Medium Priority
?
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 33

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 33

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses

762 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