Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > New window - exact size...

Reply
Thread Tools

New window - exact size...

 
 
Domestos
Guest
Posts: n/a
 
      06-28-2005
Hi all,

I need to open a HTML/PHP window with the dimensions 300x300 after clicking
an image on the source page. How on earth do I do this - I have searched
around the web and found various muck that hasn't helped me much...

Ideally I would like the window to appear without the menus and icons...

Thanks
Andy Mak




 
Reply With Quote
 
 
 
 
Edwin van der Vaart
Guest
Posts: n/a
 
      06-28-2005
Domestos wrote:
> Hi all,
>
> I need to open a HTML/PHP window with the dimensions 300x300 after clicking
> an image on the source page. How on earth do I do this - I have searched
> around the web and found various muck that hasn't helped me much...
>
> Ideally I would like the window to appear without the menus and icons...

Use a "make new window" script with js.
e.g.
Between the <head>
<script type="text/js">
var newWindow
function makeNewWindow() {
newWindow =
window.open("url","sub","toolbar=no,location=no,re sizable=no,status=no,scrollbars=no,menubar=no,pers onalbar=no,widht=300px,height=300px")
}
</script>

Some on the source file
<a href="url_image" onClick="makeNewWindow1();return false"><img
src"url_thumbnail"></a>
--
Edwin van der Vaart
http://www.semi-conductor.nl/ Links to Semiconductors sites
http://www.evandervaart.nl/ Under construction
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      06-28-2005
Edwin van der Vaart a écrit :
> Domestos wrote:
>
>> Hi all,
>>
>> I need to open a HTML/PHP window with the dimensions 300x300 after
>> clicking
>> an image on the source page. How on earth do I do this - I have searched
>> around the web and found various muck that hasn't helped me much...
>>
>> Ideally I would like the window to appear without the menus and icons...

>
> Use a "make new window" script with js.
> e.g.
> Between the <head>
> <script type="text/js">


It should be

<script type="text/javascript">

> var newWindow


It's better to set the global variable to null and not to undefined.

var newWindow = null;

> function makeNewWindow() {
> newWindow =
> window.open("url","sub","toolbar=no,location=no,re sizable=no,status=no,scrollbars=no,menubar=no,pers onalbar=no,widht=300px,height=300px")
>


If the windowFeatures string list is not empty, then there is no need to
set all these features to no. Also, width is mispelled and width and
height values as given will be ignored since px is not parsed by
browsers. So the result (window dimensions) will be unknown in browsers
here. Since you've specifically made that window non-resizable and
non-scrollable, you're possibly going to create unaccessible and
unusable windows most of the time for users.
It's always best to set resizable to yes and scrollbars to yes: if your
code has problems, whatever they are, the created window will always be
usable and accessible.
Your code also ignore margin set on root elements for secondary windows.
It's 15px 10px for MSIE users. So here, even if your windowFeatures
string list code was to be correct, at least 30px of the image would be
clipped in MSIE.

Finally, your code is not reusable: it will only work for the url_image.
It will not work if javascript is disabled either since target is not
defined but is in the function.
Also, if the window is already opened, when clicking the link, the
already opened window will not be brought up back on top and that is the
nr 1 usability problem for users with sites opening new windows.

The example
http://developer-test.mozilla.org/en...Best_practices
solve all these issues.

> }
> </script>
>
> Some on the source file
> <a href="url_image" onClick="makeNewWindow1();return false"><img
> src"url_thumbnail"></a>



Gérard
--
remove blah to email me
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      06-28-2005
On 28/06/2005 23:24, Gérard Talbot wrote:

[snip]

> It's better to set the global variable to null and not to undefined.


I fail to see why. The variable will type-convert to boolean false in
just the same way, and the code that you cite doesn't attempt to make
any distinction between two values.

The rest I agree with, though if we're talking best practices, the code
suggested by Mozilla should also test to make sure that the open and
focus methods exist before calling them in case a user is using a proxy
or third-party pop-up blocker that effectively deletes or fakes the
former, thus making the latter non-existent.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      06-28-2005
Michael Winter wrote :
> On 28/06/2005 23:24, Gérard Talbot wrote:
>
> [snip]
>
>> It's better to set the global variable to null and not to undefined.

>
>
> I fail to see why. The variable will type-convert to boolean false in
> just the same way, and the code that you cite doesn't attempt to make
> any distinction between two values.
>


It's better to initialize the variable to null rather to undefined as
later parts of the code test for/compare the reference to null and not
to undefinded. You avoid the browser to type convert that. It's no biggie.

> The rest I agree with, though if we're talking best practices, the code
> suggested by Mozilla should also test to make sure that the open and
> focus methods exist before calling them


There is no browser that supports window.open() that does not support
window.focus().

in case a user is using a proxy
> or third-party pop-up blocker that effectively deletes or fakes the
> former, thus making the latter non-existent.
>
> [snip]
>
> Mike
>



I'm not saying you're wrong about what you say up here about open being
faked: I just do not know about that particular issue.
[...After deeper thinking...] If open() is faked, then
WindowObjectReference will be null and the WindowObjectReference.focus()
will create a js error.

Gérard
--
remove blah to email me
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      06-28-2005
On 29/06/2005 00:14, Gérard Talbot wrote:

[snip]

> It's better to initialize the variable to null rather to undefined as
> later parts of the code test for/compare the reference to null and not
> to undefinded.


That comparison is equivalent. I should have pre-empted that in my
previous post - my apologies. See section 11.9.3 - The Abstract Equality
Comparison Algorithm[1] in ECMA-262 3rd Ed., specifically steps 1, 14,
and 15.

[snip]

> There is no browser that supports window.open() that does not support
> window.focus().


The issue isn't browser support as such, but that of pop-up blockers
(which is why I mentioned them). However, your statement is quite a
wide-ranging one that is difficult to substantiate either way.

[snip]

> If open() is faked, then WindowObjectReference will be null and the
> WindowObjectReference.focus() will create a js error.


Not necessarily. It is known that there are pop-up blockers which
produce code that returns non-null values from overridden open methods.
These resulting objects are usually made to appear like a global
(window) object, and may in fact be synonymous with the global object
for the current browser/tab instance, but not always. As I said, if
we're talking best practice then code should prepare itself for these
possibilities.

If you're really interested, read through the archive of
comp.lang.javascript on the subject of pop-up blockers.

Mike


[1] The Abstract Equality Comparison Algorithm

The comparison x == y, where x and y are values, produces
true or false. Such a comparison is performed as follows:

1. If Type(x) is different from Type(y), go to step 14.
...
14. If x is null and y is undefined, return true.
15. If x is undefined and y is null, return true.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
John Dunlop
Guest
Posts: n/a
 
      06-29-2005
Gérard Talbot wrote:

> Edwin van der Vaart a écrit :
>
> > <script type="text/js">

>
> It should be
>
> <script type="text/javascript">


What makes you say that?

--
Jock

 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      06-29-2005
On 29/06/2005 22:00, John Dunlop wrote:

> Gérard Talbot wrote:
>
>> Edwin van der Vaart a écrit :
>>
>>> <script type="text/js">

>>
>> It should be
>>
>> <script type="text/javascript">


In truth, there is no correct MIME type as none have been officially
registered. However, there are two widely recognised values:
text/javascript and application/x-javascript. I prefer the former, but
Apache, for example, uses the latter by default. I'm not sure which is
the most appropriate (in terms of application versus text).

> What makes you say that?


Well try using the first with a very simple script:

<script type="text/js">
alert('Media type acceptable');
</script>

I doubt you'll find it working in any browser as they correctly reject a
script type that they don't understand. You'll have more luck with the
two I mention above (though IE rejects the application type).

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
David Håsäther
Guest
Posts: n/a
 
      06-29-2005
Michael Winter <(E-Mail Removed)> wrote:

>>>> <script type="text/js">
>>>
>>> It should be
>>>
>>> <script type="text/javascript">

>
> In truth, there is no correct MIME type as none have been
> officially registered.


I read this just today: <http://www1.ietf.org/mail-archive/web/ietf-
announce/current/msg01349.html>

--
David Håsäther
 
Reply With Quote
 
John Dunlop
Guest
Posts: n/a
 
      06-30-2005
Michael Winter wrote:

[about <text/javascript>]

> there is no correct MIME type as none have been officially registered.


Yes, right, though I wouldn't be bringing notions of
'correctness' into it!

> However, there are two widely recognised values: text/javascript and
> application/x-javascript.


The first violates MIME, and the second is a private value.

The link David gave - I hadn't read it until today either -
suggests <application/javascript> will shortly be registered.

> I'm not sure which is the most appropriate (in terms of application versus
> text).


Bjöern's draft, if it makes it, would render <text/javascript>
OBSOLETE, 'no longer believed appropriate for use'. Tallyho!

--
Jock
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
jdk new version exact link! XENON Java 4 06-29-2007 05:02 AM
How to post the data to a new window and control the new window's property? Matt ASP .Net 2 08-23-2004 05:29 PM
How to post the data to a new window and control the new window's property? Matt Java 1 08-22-2004 09:09 PM
How to use an asp:button to create a new browser window and output contents to new window =?Utf-8?B?Tm92aWNl?= ASP .Net 2 06-09-2004 10:54 PM
How do u return a new object; an exact copy of the object which it is called? Jazz Java 3 10-28-2003 05:59 PM



Advertisments