Making window fit contents in all browsers? | | |
I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
IE6, IE7, Firefox 2, and wherever else practicable, with the control
labelled F.X0 fully visible at the top of the window and the control
F.Result (which is just under the textarea) fully visible at the bottom
of the window.
What's the right, or best, way to do that? It's right in IE6 at
present, and near enough so in FF2 if there's only a single tab. But
the "tab bar" spoils it in FF2 (and a little space is wasted in IE7).
I also want the width of the window to be just big enough for the layout
etc., but that's about right at present anyway, though FF2 gives wider
buttons than IE 4/6.
FYI : RegExp \s recognises character \u2029 in FF2 but not in IR6.
Therefore, a new js-quick.htm uses \u2302 instead. Paragraphs should
not contain houses.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links. | | | | re: Making window fit contents in all browsers?
Dr J R Stockton said the following on 4/17/2007 2:20 PM: Quote:
I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
IE6, IE7, Firefox 2, and wherever else practicable, with the control
labelled F.X0 fully visible at the top of the window and the control
F.Result (which is just under the textarea) fully visible at the bottom
of the window.
>
What's the right, or best, way to do that?
Ask the user to resize the window. Otherwise it is anti-social behavior
at best. And, resizing windows can be explicitly disabled in Mozilla
based browsers.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ | | | | re: Making window fit contents in all browsers?
In comp.lang.javascript message <lcCdnd2J5NIyBbvb4p2dnA@giganews.com>,
Wed, 18 Apr 2007 18:17:05, Randy Webb <HikksNotAtHome@aol.composted: Quote:
>Dr J R Stockton said the following on 4/17/2007 2:20 PM: Quote:
>I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
>IE6, IE7, Firefox 2, and wherever else practicable, with the control
>labelled F.X0 fully visible at the top of the window and the control
>F.Result (which is just under the textarea) fully visible at the bottom
>of the window.
> What's the right, or best, way to do that?
>
>Ask the user to resize the window. Otherwise it is anti-social behavior
>at best. And, resizing windows can be explicitly disabled in Mozilla
>based browsers.
Don't be dictatorial. If you had read the page, you would have realised
that it is primarily for my own use, and secondarily for others to copy
and adapt if they wish. If they don't like what it does, the remedy is
in their hands.
I use the page so often (locally) that it would really be convenient to
have it always set itself to show just what I want - which in any case
is what any regular user of a copy would want - and it's much easier to
remove such a feature than to add it.
Additional : in FF2, as well as the tabs encroaching on the target area,
I think the FIND bar also does so.
Subsequently : (BTW, forget about the house; it's gone)
In "Pack", I want any vertical whitespace (typically two or more
newlines) to be considered as a paragraph separator. In IE,
S = S.split(/(\s*\r?\n\s*){2,}/)
splits the input string S into an array of paragraphs. But in FF2, that
puts a runt paragraph in between each pair of proper ones, leading to
poor results. I could include code to strip runts, but I'd rather get a
better RegExp. Any ideas?
INFO : In a Firefox TextArea, newline seems to be just character 10; in
IE, it seems to be a pair 13,10. But AFAICS that should not matter.
Of course, I'd like it to work properly in all other browsers too.
BTW, I also auto-re-size my browser's Home Page (that's not my site's
Home Page); and in it I have links for other sizes..
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ. | | | | re: Making window fit contents in all browsers?
Dr J R Stockton wrote: Quote:
I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
IE6, IE7, Firefox 2, and wherever else practicable, with the control
labelled F.X0 fully visible at the top of the window and the control
F.Result (which is just under the textarea) fully visible at the bottom
of the window.
>
see if this works onload-
resizeTo(document.forms.F.offsetWidth,document.for ms.F.offsetHeight);document.forms.F.X0.scrollIntoV iew() | | | | re: Making window fit contents in all browsers?
Dr J R Stockton said the following on 4/19/2007 11:39 AM: Quote:
In comp.lang.javascript message <lcCdnd2J5NIyBbvb4p2dnA@giganews.com>,
Wed, 18 Apr 2007 18:17:05, Randy Webb <HikksNotAtHome@aol.composted: Quote:
>Dr J R Stockton said the following on 4/17/2007 2:20 PM: Quote:
>>I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
>>IE6, IE7, Firefox 2, and wherever else practicable, with the control
>>labelled F.X0 fully visible at the top of the window and the control
>>F.Result (which is just under the textarea) fully visible at the bottom
>>of the window.
>> What's the right, or best, way to do that?
>Ask the user to resize the window. Otherwise it is anti-social behavior
>at best. And, resizing windows can be explicitly disabled in Mozilla
>based browsers.
>
>
Don't be dictatorial.
Hmmm. Let me think this out here now. You want to force a browser window
size onto your users. Yet you call me "dictatorial" for telling you it
was a bad idea. Interesting line of thought you have sometimes.
If you had read the page,
You know, as well as anybody else here, that a Usenet post should stand
on its own merits without having to resort to reading a webpage in order
to understand a question you pose here, unless it states in your post
(which it didn't) that the question was further explained in the page.
And, you might want to add "opened and " after the third word of that
sentence. Quote:
you would have realised that it is primarily for my own use,
Again, you are assuming - incorrectly - that I even opened the page,
much less read it. The onus is on you, as the OP, to explain your
question, it is not up to me to guess what your intentions are. Quote:
and secondarily for others to copy and adapt if they wish.
If they don't like what it does, the remedy is in their hands.
Yes, and it involves leaving the site and not returning. Quote:
I use the page so often (locally) that it would really be convenient to
have it always set itself to show just what I want - which in any case
is what any regular user of a copy would want - and it's much easier to
remove such a feature than to add it.
You seem to know, before asking, what anybody else wants, and you call
me dictatorial. Interesting. Quote:
Additional : in FF2, as well as the tabs encroaching on the target area,
I think the FIND bar also does so.
You need two events:
1) window.onload
2) window.onresize
Both will call the same function.
You need four dimensions:
1) window width
2) window height
3) canvas width
4) canvas height
You know the canvas height and width you want it to display it. You read
the current size, determine how much larger/smaller to make it to meet
your desires. Then you read the window width and height and resize
accordingly. The onresize is to handle the tabs changing the size of the
canvas area. Quote:
Subsequently : (BTW, forget about the house; it's gone)
The only thing gone are a few flowers the dogs dug up. Quote:
BTW, I also auto-re-size my browser's Home Page (that's not my site's
Home Page); and in it I have links for other sizes..
What you do on your own PC is your own business. Trying to force a
browser window size on a web site is irresponsible behavior of a web
author. I am pretty sure Alan has said that before.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ | | | | re: Making window fit contents in all browsers?
In comp.lang.javascript message <1177129531.448787.249730@o5g2000hsb.goo
glegroups.com>, Fri, 20 Apr 2007 21:25:31, scripts.contact
<scripts.contact@gmail.composted: Quote:
>
>Dr J R Stockton wrote: Quote:
>I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
>IE6, IE7, Firefox 2, and wherever else practicable, with the control
>labelled F.X0 fully visible at the top of the window and the control
>F.Result (which is just under the textarea) fully visible at the bottom
>of the window.
>>
>
>see if this works onload-
>resizeTo(document.forms.F.offsetWidth,document.fo rms.F.offsetHeight);do
>cument.forms.F.X0.scrollIntoView()
The words "Scroll Into View" do not express what I want there; but
method .scrollIntoView actually does what I want. So far so good.
The textarea is set to width 99% (and other controls conform) so ISTM
better at present to leave the width code as is. I might try setting
the textarea to cols=72, then the page width to fit that, then the
textarea to 99%.
The height does not seem to work right in IE though it does in FF.
Still, there's been some progress; thanks.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm. | | | | re: Making window fit contents in all browsers?
In comp.lang.javascript message <qvKdnfjCHvFsBbTb4p2dnA@giganews.com>,
Sat, 21 Apr 2007 00:55:03, Randy Webb <HikksNotAtHome@aol.composted: Quote:
>Dr J R Stockton said the following on 4/19/2007 11:39 AM: Quote:
>In comp.lang.javascript message <lcCdnd2J5NIyBbvb4p2dnA@giganews.com>,
>Wed, 18 Apr 2007 18:17:05, Randy Webb <HikksNotAtHome@aol.composted: Quote:
>>Dr J R Stockton said the following on 4/17/2007 2:20 PM:
>>>I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
>>>IE6, IE7, Firefox 2, and wherever else practicable, with the control
>>>labelled F.X0 fully visible at the top of the window and the control
>>>F.Result (which is just under the textarea) fully visible at the bottom
>>>of the window.
>>> What's the right, or best, way to do that?
>>Ask the user to resize the window. Otherwise it is anti-social behavior
>>at best. And, resizing windows can be explicitly disabled in Mozilla
>>based browsers.
> Don't be dictatorial.
>
>Hmmm. Let me think this out here now. You want to force a browser
>window size onto your users. Yet you call me "dictatorial" for telling
>you it was a bad idea. Interesting line of thought you have sometimes.
>
>If you had read the page,
Missing - I wrote those six words. Quote:
>You know, as well as anybody else here, that a Usenet post should stand
>on its own merits without having to resort to reading a webpage in
>order to understand a question you pose here, unless it states in your
>post (which it didn't) that the question was further explained in the
>page.
>
>And, you might want to add "opened and " after the third word of that
>sentence.
Undefined : "that". Quote: Quote:
>you would have realised that it is primarily for my own use,
>
>Again, you are assuming - incorrectly - that I even opened the page,
>much less read it. The onus is on you, as the OP, to explain your
>question, it is not up to me to guess what your intentions are.
No : "If you had read the page," expresses a possibility but not an
expectation. It's the sort of thing that a reasonable person would do
before commenting about whether re-sizing and scrolling was appropriate
for the page in question.
But, in order to answer the question as I asked it, there was no real
need to visit the page, although that might have helped.
Of course, in the ordinary commercial environment, resizing larger is
arrogance and forces the ordinary reader to accept something unwanted.
Different considerations apply in a page which is not only part of a
javascript site but which is specifically aimed at those who are
currently active programmers - if they're not capable of amending a
local copy, they're in the wrong place anyway. Quote: Quote:
>and secondarily for others to copy and adapt if they wish. If they
>>don't like what it does, the remedy is in their hands.
>
>Yes, and it involves leaving the site and not returning.
If they wish, yes. It's primarily for my own use, both locally and
remotely. In fact, as I say on the page, I don't *want* people to use
it much, but to use a copy instead. Quote: Quote:
>I use the page so often (locally) that it would really be convenient to
>have it always set itself to show just what I want - which in any case
>is what any regular user of a copy would want - and it's much easier to
>remove such a feature than to add it.
>
>You seem to know, before asking, what anybody else wants, and you call
>me dictatorial. Interesting.
Indeed, the design of the page is such that I do know what they will
want when visiting the page, unless they visited it in error. The rest
of the material on it is only for reference, and will be read
infrequently. If you had visited the page, you would have realised
that. Quote: Quote:
>Additional : in FF2, as well as the tabs encroaching on the target area,
>I think the FIND bar also does so.
Quote:
>You know the canvas height and width you want it to display it.
No, I do not. I know the internal height of the textarea in characters,
and the width in percent, but I don't know the size of F in pixels. F
contains other controls.
ISTR seeing a Method for getting position; but I cannot recall what it
is. Quote:
>What you do on your own PC is your own business. Trying to force a
>browser window size on a web site is irresponsible behavior of a web
>author. I am pretty sure Alan has said that before.
Do you mean the late Alan? Or one who posts here?
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036) | | | | re: Making window fit contents in all browsers?
Dr J R Stockton said the following on 4/21/2007 5:53 PM: Quote:
In comp.lang.javascript message <qvKdnfjCHvFsBbTb4p2dnA@giganews.com>,
Sat, 21 Apr 2007 00:55:03, Randy Webb <HikksNotAtHome@aol.composted: Quote:
>Dr J R Stockton said the following on 4/19/2007 11:39 AM: Quote:
>>In comp.lang.javascript message <lcCdnd2J5NIyBbvb4p2dnA@giganews.com>,
>>Wed, 18 Apr 2007 18:17:05, Randy Webb <HikksNotAtHome@aol.composted:
>>>Dr J R Stockton said the following on 4/17/2007 2:20 PM:
>>>>I want page <URL:http://www.merlyn.demon.co.uk/js-quick.htmto open, in
>>>>IE6, IE7, Firefox 2, and wherever else practicable, with the control
>>>>labelled F.X0 fully visible at the top of the window and the control
>>>>F.Result (which is just under the textarea) fully visible at the bottom
>>>>of the window.
>>>> What's the right, or best, way to do that?
>>>Ask the user to resize the window. Otherwise it is anti-social behavior
>>>at best. And, resizing windows can be explicitly disabled in Mozilla
>>>based browsers.
>> Don't be dictatorial.
>Hmmm. Let me think this out here now. You want to force a browser
>window size onto your users. Yet you call me "dictatorial" for telling
>you it was a bad idea. Interesting line of thought you have sometimes.
>>
>If you had read the page,
>
Missing - I wrote those six words.
> Quote:
>You know, as well as anybody else here, that a Usenet post should stand
>on its own merits without having to resort to reading a webpage in
>order to understand a question you pose here, unless it states in your
>post (which it didn't) that the question was further explained in the
>page.
>>
>And, you might want to add "opened and " after the third word of that
>sentence.
>
Undefined : "that".
"that" = The sentence that starts with "If you had read the page". Quote: Quote: Quote:
>>you would have realised that it is primarily for my own use,
>Again, you are assuming - incorrectly - that I even opened the page,
>much less read it. The onus is on you, as the OP, to explain your
>question, it is not up to me to guess what your intentions are.
>
No : "If you had read the page," expresses a possibility but not an
expectation. It's the sort of thing that a reasonable person would do
before commenting about whether re-sizing and scrolling was appropriate
for the page in question.
No, as it is *never* "appropriate" to resize a users browser window
without explicit permission and simply opening a page does not give that
permission. Quote:
But, in order to answer the question as I asked it, there was no real
need to visit the page, although that might have helped.
Precisely and I didn't open the page. Hence my suggestion to add "opened
and " to "that" sentence. Quote:
Of course, in the ordinary commercial environment, resizing larger is
arrogance and forces the ordinary reader to accept something unwanted.
Resizing at all, whether larger or smaller, is ignorant arrogance. Which
is what lead you to call me "dictatorial" yet now you are agreeing with
me. Interesting. Quote: Quote: Quote:
>>and secondarily for others to copy and adapt if they wish. If they
>>don't like what it does, the remedy is in their hands.
>Yes, and it involves leaving the site and not returning.
>
If they wish, yes. It's primarily for my own use, both locally and
remotely. In fact, as I say on the page, I don't *want* people to use
it much, but to use a copy instead.
Again, what you say on the page itself is irrelevant as you have already
resized the browser, without permission, before a person even has a
change to read the page. Quote: Quote: Quote:
>>I use the page so often (locally) that it would really be convenient to
>>have it always set itself to show just what I want - which in any case
>>is what any regular user of a copy would want - and it's much easier to
>>remove such a feature than to add it.
>You seem to know, before asking, what anybody else wants, and you call
>me dictatorial. Interesting.
>
Indeed, the design of the page is such that I do know what they will
want when visiting the page, unless they visited it in error.
Are you a mind reader now? You must be if you can claim to know what a
visitor wants before visiting. Quote:
The rest of the material on it is only for reference, and will be read
infrequently. If you had visited the page, you would have realised
that.
Again, the content of the page is irrelevant to your question. Quote: Quote: Quote:
>>Additional : in FF2, as well as the tabs encroaching on the target area,
>>I think the FIND bar also does so.
> Quote:
>You know the canvas height and width you want it to display it.
>
No, I do not. I know the internal height of the textarea in characters,
and the width in percent, but I don't know the size of F in pixels. F
contains other controls.
Size the window the size you want it. Then, you read the canvas height
and width. Then you know F in pixels. FAQ 4.9 has code to determine the
canvas area. That canvas size will be fixed. Call them
desiredCanvasHeight and desiredCanvasWidth. Then, onload/onresize of the
page, you read the current canvasHeight and current canvasWidth.
Whatever the difference in the two sizes, you know you have to resize
the window by that many pixels. Then you read the window height/width
and resize it accordingly. Then it won't matter what toolbars/tabs or
anything else is showing, you get the canvas area you are after. The
onresize could be tricky as it may or may not get fired if tabs cause
the canvas area to be slightly smaller, you would have to test it. Quote: Quote:
>What you do on your own PC is your own business. Trying to force a
>browser window size on a web site is irresponsible behavior of a web
>author. I am pretty sure Alan has said that before.
>
Do you mean the late Alan? Or one who posts here?
The late Alan.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |  | Similar JavaScript / Ajax / DHTML bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,223 network members.
|