Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: open new window

  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    433
    Thanks
    3
    Thanked 0 Times in 0 Posts

    open new window

    i want to open a new window in the picture dimensions
    Ia m using the folowing code to resize the window
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
    <script language="JavaScript">
    var number=document.URL
    var number=number.split('/');
    var mikos=number.length;
    var eikona=number[mikos-1]; //1.htm
    var mikos=eikona.length;
    var eikona=eikona.substr(0,mikos-4);

    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <div align="center"> <a href="javascript:window.close();"><img src="" name="pic1" border="0" alt=" " height="300">
    </a>
    <script language="JavaScript">

    document.images['pic1'].src=eikona+".jpg";
    setTimeout("resize();",500);
    function resize()
    {
    var width=document.images['pic1'].width;
    var height=document.images['pic1'].height;+
    window.resizeTo(width,height);
    if (window.screen) {
    self.moveTo((screen.availWidth-width)/2,(screen.availHeight-height)/2);
    }
    }
    </script>
    </div>
    </body>
    </html>

    the main problem is that when the window opens is very small because (<img src="" name="pic1" border="0" alt=" " height="300"> ) and the bigger picture is being loaded in the small window.What i must do.. I was thinging to use the onload to resample the wind?ow to the picture! plz help me

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ala...
    one of the other just a forum members...reyn...just a posted this before...
    Code:
    Well, that's just a matter of knowing the image's dimensions beforehand, and using that as the parameters for opening a window of the specified size.
    This simple reusable function can be called by any link that passes it the image filename, and the height and width of the image, then pops out the image in a new window of approximately that size.
    
                        Somewhere in the HEAD, insert:
    
                        <script language="JavaScript">
                        <!--
                        function show(pic,h,w){
                        var size="height="+h+",width="+w;
                        var show=open(pic,'',size)}
                        //-->
                        </script>
    
    And for example, you want to show an image 300 pixels high x 300 pixels wide. Then just call the function and pass it the correct parameters, in this order: filename.jpg, height, and width.
    
    <a href="javascript:show('mypic.jpg',320,320)">Show me</a>
    
    The added 20 is optional to offset for the default top and left margins of browsers.
    just a goodluck :O)))


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •