Opening a popup window faster

M

Mehmet Gunacti

Hello,

on our homepage, when pressing an anchor tag, a special sized popup
window opens via javascript. but it opens very slowly.

on other web pages, there are also javascript-opened windows, but they
load very very fast, within 2-3 seconds.

i tried several things such as :

// directly in href attribute
<a href="javascript:window.open('the_url','','toolbar=0, location=0,
directories=0, status=0, menuBar=0, scrollBars=1, resizable=0,
width=624, height=500, top=15');">test1</a>

// in an onclick event
<a href="#" onclick="javascript:window.open('the_url','','toolbar=0,
location=0, directories=0, status=0, menuBar=0, scrollBars=1,
resizable=0, width=624, height=500, top=15');">test2</a>


// or in a function, first open popup,
// then load content into popup via reference
var anotherPopup = null;
function openAnotherPopup() {
anotherPopup = window.open('','anotherPopup','width=600,height=323,status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,resizable=yes,alwaysRaised=no,screenX=20,screenY=5,titlebar=yes,z-lock=yes,left='
+ (screen.width - 728) / 2 + ',top=' + (screen.height - 586) / 2);
anotherPopup.location = "the_url";
anotherPopup.focus();
}


in the web page i've mentioned before (the one that opens popups very
fast) the first approach is used.

i use IE 6.0, windows 2000 prof and have 1 gb ram.
the popups of our site doesn't open a bit faster even no other
application is running on my system.

firefox opens the popup very fast, ok, but how does it come, that IE
6.0 opens a popup of a site much faster than the popups of another ?
can anybody help with this problem ?
 
M

Michael Winter

[snip]
<a href="javascript:window.open('the_url','','toolbar=0, location=0,
directories=0, status=0, menuBar=0, scrollBars=1, resizable=0,
width=624, height=500, top=15');">test1</a>

1) It's almost always wrong to use the javascript: pseudo-protocol
in links[1]. In this particular case, it most certainly is. Never
open a pop-up like this. Not only will users without Javascript
be unable to reach the page, but people like me who middle-click
links[2] will get nothing but a blank page.
2) The feature string should not contain spaces.
3) You should never attempt to make a window fixed in size, nor
attempt to remove the status bar. Decent browsers won't let you,
anyway.

The more acceptable way to present that link would be:

<a href="http://www.example.com/" target="myWindow"
onclick="window.open(this.href, this.target,
'status,scrollbars,resizable,width=624,height=500,top=15');
return false;">

Now it will work for everyone.

Notice that I omitted several of the features - those that are missing are
automatically disabled (with an exception or two, like the title bar).

[snip]

Mike


[1] I would *always* consider it wrong on the Web.
[2] Middle-clicking a link in most (all?) tabbed browsers opens the
link in a new tab.
 
M

Michael Winter

[...] the opening windows' size was not my decision,

It's not necessarily the size that's a problem, but the fact that original
code tried to prevent the window from being resized. What if a user
overrides the font sizes and makes them larger to compensate for their
poor eyesight? Thankfully the window would provide scrollbars, but it
would be much nicer if the user could make them unnecessary by making the
window bigger.

[snip]
but the popup still opens very very slowly. the opener window freezes
until the popup appears. do you know a way to make this faster ?

No, not really. The speed at which a new window opens will vary based on
what the window will contain (complex nested tables [which should be
avoided] will take longer to render than simple semantic mark-up), how
well the browser was written, and various load factors on the computer.
So, aside from making sure your mark-up is simple (and valid), I doubt
there is anything you can do.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top