|
Posted by Gιrard Talbot on 06/29/05 01:24
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,resizable=no,status=no,scrollbars=no,menubar=no,personalbar=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/docs/window.open#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
Navigation:
[Reply to this message]
|