The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Closing the Windows, 6.4. How do I create a link that opens a new window of a specific size
Number1
post Mar 25 2013, 02:03 PM
Post #1


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



The above FAQ section seems fine, but it leaves out one crucial concern:

How to ensure that you aren't unknowingly stacking up windows behind the active ones? When you have a function, such as on most of the product pages at www.seco-larm.com, that creates a new window simply to temporarily display a blowup of a photo or diagram, it's important that that window goes away when it loses focus, or the customer can find himself inundated with these small windows.

Here's the code that accomplishes that in all but the most unusual cases.

In the Head you put the call to the external js: <CODE><script type="text/javascript" src="VideoAcc.js"></script></CODE>

and,
<CODE><script language="Javascript">
function PopLink(x){window.open("PopUps/"+x, "popups", "width=450, height=274, resizable=yes, scrollbars=no, left=200, top=200");}
function PopLink2(x){window.open("PopUps/"+x, "popups", "width=460, height=430, resizable=yes, scrollbars=no, left=200, top=200");}
</script></CODE>

and,

<code><body style="FONT-FAMILY: Tahoma, Verdana, Arial;" bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 onfocus="closesrchwin()"></code>

And, in the external js "VideoAcc.js",
<code>var srchwin = false;
function opensrchwin()
{srchwin = window.open('SearchVideo.htm','mywin','resizable=yes, scrollbars=yes,width=340,height=90');
return false;}
function closesrchwin()
{if(srchwin) { srchwin.close(); srchwin = false; }}</code>

And then the window gets called via a link as:
<code><table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td width=100% align=center><A HREF="java script:PopLink('4PortHub.htm');"><div class=pr><font class=size8>View Enlargement</font></div></a></td></tr></code>

This is script kiddie hacking, of course, but someone who has a greater understanding could likely make it more clear, I'm sure...

This post has been edited by Number1: Mar 25 2013, 02:06 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 25 2013, 02:09 PM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,350
Joined: 9-August 06
Member No.: 6



Are you sure you want that? It irritates me no end when sites do that. The reason is a like to keep the windows with products (or whatever) I'm interested in open and compare them.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 25 2013, 03:36 PM
Post #3


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



Also this isn't user-friendly:

CODE
<A HREF="java script:PopLink('4PortHub.htm');">

if the user tries to right-click or bookmark, the link doesn't work even with javascript enabled. Make it an ordinary link instead, as shown in the FAQ.

If a popup must somehow be kept together with its parent web page, I'd use a "DHTML popup" instead (i.e., an HTML element that's made visible by javascript in front of the other content, similar to many image viewer script in use today).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 25 2013, 04:31 PM
Post #4


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



This isn't for all applications, for sure, as there are times when you clearly want a window to stick around. What frequently happens tho, is that the user clicks on a link that opens the window and then clicks back in the document, not thinking about that new window that is now behind the document, where it will stay until closed.

Then they do it 15 more times. The method I used ensures that the window definitely goes away, which is fine most of the time, when the user just wants a quick glance at a specific piece of info. I experimented with other schemes, such as a timer on how long the window would stay up, but the simple way ended up as the one that seemed best suited.

Note that I do use a persistant window for the keyword search engine, for exactly the reason that Pandy gives. And management complained about that. "Why would anyone ever want to have more than one window open at a time?" (ROFL)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 25 2013, 06:32 PM
Post #5


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



Edit: sorry, misunderstood the thread's purpose. Thought you wanted to avoid multiple popups yourself. blush.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 25 2013, 06:42 PM
Post #6


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



QUOTE(Christian J @ Mar 25 2013, 06:32 PM) *

Edit: sorry, misunderstood the thread's purpose. Thought you wanted to avoid multiple popups yourself. blush.gif

No problem. I was pointing out what I thought ought to be included in the FAQ, but strictly from my own standpoint of controlling screen clutter for the user. Probably such a section of the FAQ should include the other options as well. I.e., does the user likely want to retain every popup window that opens with the option of deliberately closing them, or is it more likely that the user would want a popup to automatically go away on losing focus. This will vary radically depending upon the site and nature of the information.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 25 2013, 06:47 PM
Post #7


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,350
Joined: 9-August 06
Member No.: 6



That's why letting the user choose for himself is best.

BTW I totally don't understand what this thread is about now. biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 26 2013, 10:34 AM
Post #8


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



Pandy

I was just checking out your FAQ, and ran across the entry about opening a new window. I didn't see anything about controlling when the new window would close. It's been most of a decade since I did the coding, so if were doing something wrong, it also might be useful to improve my code as well.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Mar 28 2013, 11:46 PM
Post #9


WDG Member
********

Group: Root Admin
Posts: 8,308
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
I didn't see anything about controlling when the new window would close.
Do you mean like this?
http://www.htmlhelp.com/faq/html/links.html#close-button
Or something else?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 29 2013, 12:55 PM
Post #10


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



QUOTE(Darin McGrew @ Mar 28 2013, 11:46 PM) *

QUOTE
I didn't see anything about controlling when the new window would close.
Do you mean like this?
http://www.htmlhelp.com/faq/html/links.html#close-button
Or something else?


That's a start, but doesn't really address the problem that I brought up. It is annoying and potentially hazardous to have multitudes of windows hiding behind your front page, but that can happen if you don't have a method for automatically closing them. The method I used simply closed the window any time it lost focus, which I think was the best overall option for windows that mainly just displayed an expanded product photo.

This post has been edited by Number1: Mar 29 2013, 01:19 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 29 2013, 01:21 PM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,350
Joined: 9-August 06
Member No.: 6



And why can't you do that now?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 29 2013, 02:06 PM
Post #12


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



Here is what often happens. The user clicks on the link that opens the popup window with the product photo. Not realizing that that window will drop behind whatever is next clicked on the user clicks on the parent window and very likely the popup is now hidden. Repeat several times and you've got a stack of windows open that you didn't even know about.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 29 2013, 02:47 PM
Post #13


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



I think there are two way to avoid that:

Using popup windows, IIRC you can give all of them the same name/target. That way a new popup should replace the previous one with the same name.

Or you could use a "modal window". Usually that's made with an HTML element positioned in front of the page's normal content (using CSS and javascript), which means it's always contained within the associated parent page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 29 2013, 04:03 PM
Post #14


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,350
Joined: 9-August 06
Member No.: 6



QUOTE(Number1 @ Mar 29 2013, 08:06 PM) *

Here is what often happens. The user clicks on the link that opens the popup window with the product photo. Not realizing that that window will drop behind whatever is next clicked on the user clicks on the parent window and very likely the popup is now hidden. Repeat several times and you've got a stack of windows open that you didn't even know about.



Why wouldn't he expect that? That's what happens every time you open a new window, no matter what program you use. Unless the program uses tabs of course.

But that wasn't what I asked. I asked why you can't use the method that has worked for you before, closing the windows when they lose focus? I think the method with a reused named window is better though. Less to type if nothing else.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Number1
post Mar 29 2013, 06:06 PM
Post #15


Advanced Member
****

Group: Members
Posts: 114
Joined: 17-October 12
Member No.: 17,963



Oh, now I understand (I think). Pandy, you were thinking that I was posting due to a problem on my end. I was posting because it seemed that the FAQ left out how to control closing windows. I get annoyed at all the alerts that mean I have to interrupt everything and close them down, when I would prefer that in most cases they simply disappear on loss of focus. My usage of popup windows falls into the same sort of category. But there are clearly many alternatives.

This post has been edited by Number1: Mar 29 2013, 06:08 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 29 2013, 06:17 PM
Post #16


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,350
Joined: 9-August 06
Member No.: 6



Ah, now I understand at last! cool.gif

I don't think there has even been an ambition to have a JavaScript FAQ here. I think the few JS related things there after all is are there because those questions were so often asked. But Darin knows more about this than I do. He wrote the FAQ.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 29 2013, 06:34 PM
Post #17


.
********

Group: WDG Moderators
Posts: 8,206
Joined: 10-August 06
Member No.: 7



http://htmlhelp.com/faq/ does contain a link to http://www.irt.org/script/script.htm
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th August 2019 - 08:52 AM