Solved

windows.open keeps opening new copies of named window

Posted on 2014-11-19
5
63 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 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
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 style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

774 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