Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript; Open existing popup not being referenced 2

Status
Not open for further replies.

robz2009

Programmer
Apr 20, 2009
41
GB
I seem to have an issue where the open function in javascript is always opening new popups even though the window name is setup in the parameters. To add further confusion this is only happening on certain PC’s. I have tried in vain to see any differences but the Operating System, Browser and Java versions are all the same.

This is the open statement,

open("popunder.asp", "myPopUnder", "width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no");

Why are specific PC’s recognising this window and loading the information into the exisiting one, whereas other PC’s are creating additional popups? This is confusing the hell out of me ?!?!

Do I need to check the target popunder.asp for anything? What factors would cause the Javascript to see this window has already been loaded?
 
Hi

robz2009 said:
Do I need to check the target popunder.asp for anything?
What you can check is the [tt]Window[/tt] object, returned by [tt]open()[/tt], if you store it in a variable :
JavaScript:
[b]var[/b] popwin
[b]function[/b] [COLOR=darkgoldenrod]annoy[/color][teal]()[/teal]
[teal]{[/teal]
  [b]if[/b] [teal]([/teal]popwin [teal]&&[/teal] [teal]![/teal]popwin[teal].[/teal]closed[teal])[/teal] popwin[teal].[/teal]location[teal].[/teal]href[teal]=[/teal][green][i]'popunder.asp'[/i][/green]
  [b]else[/b] popwin[teal]=[/teal][COLOR=darkgoldenrod]open[/color][teal]([/teal][green][i]"popunder.asp"[/i][/green][teal],[/teal] [green][i]"myPopUnder"[/i][/green][teal],[/teal] [green][i]"width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no"[/i][/green][teal]);[/teal]
[teal]}[/teal]
robz2009 said:
What factors would cause the Javascript to see this window has already been loaded?
That happens to me only when the second and consecutive [tt]open()[/tt] calls are made before the first creates the target window.

Feherke.
 
This doesn't work? Isn't your if statement missing a then? Even when I put this the .asp does nothing?
 
Isn't your if statement missing a then?

Perhaps if you live in VB land, yes... in JS land, 'then' is not a valid keyword and is not required.




Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

By the way, you have to call the annoy() [tt]function[/tt] somewhere.

( I posted the code in this way, enclosed in a [tt]function[/tt] because this is the usual way it is used. Otherwise you would have to reproduce the whole [tt]if[/tt] .. [tt]else[/tt] everywhere you want to us it. )


Feherke.
 
Fair comment, point taken. But this new code does not do anything. No errors come back but I was expecting the popup?

Please note that the current asp will create the initial popup. This same line of code is referenced but because the window name is the same it doesn’t create a new window. The issue I have that on particular PC’s this is creating additional windows and I don’t know why.

To emphasise this point I created a dummy.asp with the code,

<SCRIPT Language="JavaScript">

open("popunder.asp", "myPopUnder", "width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no");
open("popunder.asp", "myPopUnder", "width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no");

</SCRIPT>


From my PC only the one window appears. From a different PC it brings up two separate windows even though the same name is used. It’s machine specific but I have compared IE, O/S and Java and it’s all the same. What else could be causing this?

I have tried to put these open statements into variables but that makes no difference.

Your help is much appreciated.


 
Perhaps that PC has some third-party browser add-on installed (e.g. Google, Yahoo toolbar, etc), or some security or popup-related software (e.g. Norton, etc)?

Have you tried a different browser on that PC to tie it down to a specific browser?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Dan - I would love to give you a laughing star for making my day with your, "Perhaps you live in VB land..." comment.

But I do give you a star for the 3rd party tool bar suggestion. That bites our users all the time. The help-desks tells them to uninstall any 3rd party toolbar, but in reality you just need to instruct the toolbar to allow pop-ups from your site. With the Google toolbar it is pretty easy. I don't know about the others.

And Fehreke, you get a laughing star for calling the function annoy() because a function name really should describe the functionality. Is there honestly a GOOD reason for a pop-under window? Isn't that the reason people have 3rd party toolbars that block stupid windows?

Both of you - thanks for making me smile today.

Einstein47 (Starbase47.com)
“PI is like love - simple, natural, irrational, endless, and very important“
 
Hi

Einstein47 said:
Is there honestly a GOOD reason for a pop-under window?
Some people invokes as reason that their document needs to be displayed in a window of certain size. However I see no reason to try to disable some of the window's functional elements.

Thanks to the JavaScript Options extension for FireFox most of the features specified in the OP's [tt]open()[/tt] call not works :
[ul]
[li][tt]width=300[/tt] - sadly, this works[/li]
[li][tt]height=100[/tt] - sadly, this works[/li]
[li][tt]status=no[/tt] - not in my browser[/li]
[li][tt]toolbar=no[/tt] - not in my browser[/li]
[li][tt]menubar=no[/tt] - not in my browser[/li]
[li][tt]scrollbars=no[/tt] - not in my browser[/li]
[li][tt]resizable=no[/tt] - not in my browser[/li]
[li][tt]alwaysLowered=yes[/tt] - not in my browser[/li]
[li][tt]location=no[/tt] - not in my browser[/li]
[li][tt]directories=no[/tt] - not in my browser[/li]
[li][tt]titlebar=no[/tt] - not in my browser[/li]
[/ul]
And there are solutions to force the [tt]open()[/tt] method's result into a tab instead of window, in which case neither the [tt]width[/tt] and [tt]height[/tt] works.

So fortunately there are browsers which listen to their owner, not an unknown webmaster.


Feherke.
 
I think this post is now venturing off in a different direction.

This software is supplied by a 3rd party so asking what is the point of popups is pointless. I am not going to change how the software works. I will now install Firefox on the users PC and see if I still get the same problem.

I have also read another article which suggests to substitute the open function for document.location.href so I will also try that.
 
This is not an issue in Firefox on the user’s PC. Only IE, very very confusing.

So my burning question is why doesn’t the javascript open function reuse the same window and instead open an additional window when called? As stated the test I have done is use this code,

<SCRIPT Language="JavaScript">

open("popunder.asp", "myPopUnder", "width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no");
open("popunder.asp", "myPopUnder", "width=300,height=100,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,alwaysLowered=yes,location=no,directories=no,titlebar=no");

</SCRIPT>


On my PC using Internet Explorer this popup appears once. On the end users PC when using Internet Explorer two popups appear?

As a test I installed Firefox on the end users PC and the popup appears once which indicates its an issue with Internet Explorer.

Their version of IE is in sync with mine? Really stuck with this now?
 
You have not confirmed whether they have any third-party add-ons or toolbars installed in IE, e.g. Google, Yahoo toolbars, etc.

Could you do that to at least rule it out?

Perhaps get them to start IE in 'no add-ons' mode. This can be done like so in XP and Vista (assuming a 'classic' start menu layout):

Start -> Programs -> Accessories -> System Tools -> Internet Explorer (No Add-ons)

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Apologies, I can confirm they don't have any third-party add-ons or toolbars installed in IE, e.g. Google, Yahoo toolbars, etc.

I disabled all the Add-Ons which were showing Sun Java Console, Windows Live Sign-in... but still no luck. This would be the same as using "Internet Explorer (No Add-ons)" wouldn't it?

I can't find the shortcut in Start -> Programs -> Accessories -> System Tools -> Internet Explorer (No Add-ons), if you have an executable name I can go direct to it and re-test if you like?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top