By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

popup refresh question

P: n/a
Hi.

I have a page that contains this simple function:

<script language="javascript">
function openPop(url, name, w, h) {
var features = "";
features += "scrollbars=no,";
features += "menubar=no,";
features += "resizable=no,";
features += "left="+Math.floor(screen.width/2-w/2)+",";
features += "top="+Math.floor(screen.height/2-h/2)+",";
features += "alwaysRaised=no,";
features += "width=" + w + ",";
features += "height=" + h;
nw = window.open(url, name, features);
}
</script>

Il opens a popup.htm using this system:
popup.htm?artist=picasso&type=maxi&nImg=3.jpg&w=49 9&h=300;

When the popup opens (it only contains an image!), it reads this url,
looks for the data and loads it into the window:

<script language='javascript'>

var qst=location.search.substr(1);
var dati = new Array()
dataInUrl=qst.split("&");
// artist name
var d1 = dataInUrl[0].substr(dataInUrl[0].indexOf("=")+1);
// folder type
var d2 = dataInUrl[1].substr(dataInUrl[1].indexOf("=")+1);
// image path
var d3 = dataInUrl[2].substr(dataInUrl[2].indexOf("=")+1);
// width
var d4 = dataInUrl[3].substr(dataInUrl[3].indexOf("=")+1);
// height
var d5 = dataInUrl[4].substr(dataInUrl[4].indexOf("=")+1);
</script>

</HEAD>
<BODY bgcolor="#000000" topmargin="0"
marginheight="0" leftmargin="0" marginwidth="0">

<script language='javascript'>
document.write( "<img src='" + path + "' border=0 height='"+d5+"'
width='"+d4+"'>" );
</script>

Everything gets loaded when wanted but:
1) the first image perfectly adheres to the border of the popup
2) when I call again the function (setting other dimensions for the
popup) I get the same dimensions as the first time I loaded the popup:
that is, if the first time I called a 300x300 popup and the second time
I specified a width of 450x340, I get again a popup 300x300 window (but
containing the right content!).

Is there any way to have the things working as I imagined? :-)

Thanks in advance,
ypress
Oct 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

ypress wrote:
Hi.
Everything gets loaded when wanted but:
1) the first image perfectly adheres to the border of the popup
2) when I call again the function (setting other dimensions for the
popup) I get the same dimensions as the first time I loaded the popup:
that is, if the first time I called a 300x300 popup and the second time
I specified a width of 450x340, I get again a popup 300x300 window (but
containing the right content!).

Is there any way to have the things working as I imagined? :-)


Send the popup the width and height you want instead (URL params), then
use the resizeTo function.
Note that some browsers give the users the ability to turn that off,
but for the most part, if someone has popups enabled, they probably
allow resizing.
Those of us who use tabbed browsers and redirect to tabs (not a new
window) turn it off so it doesn't screw up all our other open tabs.

HTH

Oct 14 '05 #2

P: n/a
ypress wrote :
Hi.

I have a page that contains this simple function:

<script language="javascript">
Language is deprecated; type has replaced language and is both backward
and forward-compatible.
function openPop(url, name, w, h) {
var features = "";
features += "scrollbars=no,";
Turning off scrollbar(s) in case content overflows requested window
dimensions is counter-usability; you are deliberately removing from the
user the ability to reach and access content in case such content is
clipped from the window view. What you are trying to do goes explicitly
against accessibility common sense and default usability fallback in
browsers.
The normal attitude should be to allow such window to render
scrollbar(s) if content overflows window dimensions.
features += "menubar=no,";
As soon as the WindowFeatures string list is not empty, all of the
configurable features are turn off. So, what you do here is useless.
features += "resizable=no,";
Same thing here. You are deliberately removing the user ability to
resize the window in case *your* imposed window dimensions clip the
content from the window view. What you do goes explicitly against
accessibility common sense.
The normal, sane fallback mechanism should be to allow such window to be
resizable.
features += "left="+Math.floor(screen.width/2-w/2)+",";
features += "top="+Math.floor(screen.height/2-h/2)+",";
Your calculations do not take into consideration the available
dimensions for applications. So this is wrong. You are miscalculating
the real available workarea for applications on the user's screen.
features += "alwaysRaised=no,";
features += "width=" + w + ",";
features += "height=" + h;
So far, your script concatenates 9 times a bunch of sub-strings and we
know that string concatenation is time consuming and resources (memory
management) consuming. E.g.:

var strExample = "";
strExample += "abc";
strExample += "def";
strExample += "ghi";
strExample += "jkl";
will be 4 times slower and resources-demanding than
var strExample = "abc" + "def" + "ghi" + "jkl";
nw = window.open(url, name, features);
}
</script>

Il opens a popup.htm using this system:
popup.htm?artist=picasso&type=maxi&nImg=3.jpg&w=49 9&h=300;

When the popup opens (it only contains an image!), it reads this url,
looks for the data and loads it into the window:

<script language='javascript'>
Language is deprecated; type has replaced language and is both backward
and forward-compatible.

var qst=location.search.substr(1);
var dati = new Array()
dataInUrl=qst.split("&");
// artist name
var d1 = dataInUrl[0].substr(dataInUrl[0].indexOf("=")+1);
// folder type
var d2 = dataInUrl[1].substr(dataInUrl[1].indexOf("=")+1);
// image path
var d3 = dataInUrl[2].substr(dataInUrl[2].indexOf("=")+1);
// width
var d4 = dataInUrl[3].substr(dataInUrl[3].indexOf("=")+1);
// height
var d5 = dataInUrl[4].substr(dataInUrl[4].indexOf("=")+1);
</script>

</HEAD>
<BODY bgcolor="#000000" topmargin="0"
marginheight="0" leftmargin="0" marginwidth="0">
If you want to remove margin on the body node, then using CSS is much
preferable than to use invalid markup code.

<script language='javascript'>
document.write( "<img src='" + path + "' border=0 height='"+d5+"'
width='"+d4+"'>" );
</script>

Everything gets loaded when wanted but:
1) the first image perfectly adheres to the border of the popup
In which browser? which browser version? What is the code of your call
function?
Are you actually saying that your image should not adhere to the border
of the popup window? Is that what you are trying to say? It isn't clear
since it seems to me that you want windows to have 0 margins.
2) when I call again the function (setting other dimensions for the
popup) I get the same dimensions as the first time I loaded the popup:
that is, if the first time I called a 300x300 popup and the second time
I specified a width of 450x340, I get again a popup 300x300 window (but
containing the right content!).
This dimensions problem would be a lot less annoying and frustrating for
the user if you had defined resizable=yes and scrollbars=yes in the
window.open() call to begin with.

Is there any way to have the things working as I imagined? :-)

Yes. Your problem is not difficult to fix. For which browsers you want
this to work? Can you provide an url for where your code, all your code
is? Without seeing how you make the function call in the opener page,
it's not possible to be sure.

Gérard
--
remove blah to email me
Oct 14 '05 #3

P: n/a
nikki wrote :
Send the popup the width and height you want instead (URL params), then
use the resizeTo function.
Note that some browsers give the users the ability to turn that off,
but for the most part, if someone has popups enabled, they probably
allow resizing.


I'd say the exact opposite. Most people disallow unrequested popups,
allow requested popups but will disable the ability of script to resize
as they wish, just like that, existing windows. Moving and resizing
windows has been abused so much before that people won't let this happen
again.

Gérard
--
remove blah to email me
Oct 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.