Solved

windows.open keeps opening new copies of named window

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

760 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