Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2004, 09:36 PM
Authorized User
 
Join Date: Jul 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening a new window with a dynamic sizing...

I would like to open up a new window to display an enlarged view of a photo the problem is that all my pictures are different sizes therefor I cannot set a size for the new window is there anyway to have to window size itself dynamically based on content...

Thank you,

Adina

 
Old November 22nd, 2004, 05:30 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you know the size of the image you can build the size dynamically. For example if the image is 400 pixels wide by 200 pixels high and are stored in variable iWidth and iHeight, then your window.open would be similar to:
Code:
window.open(<url here>, "NewWin", "width=" + iWidth + "px,height=" + iHeight + "px"  );


--

Joe (Microsoft MVP - XML)
 
Old November 23rd, 2004, 04:50 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi elladi
Try this one
Since in your case images may come from the database ,so u can put ur image source accordingly

<img src="images1.jpg" id="myimg">
<script>
myimg1=new Image()
myimg1.src="images1.jpg"

obj=document.getElementById("myimg")
window.resizeTo(obj.width,obj.height);
//inorder to manipulate your window you must specify your parameters
//for example obj.width+20 for giving extra space so that proper image can be seen
//so i prefer to use window.resizeTo(obj.width+20,obj.height+20);
</script>
Hope this will help you
Cheers :)


vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Sizing Div Width with window resizing javs Javascript 1 March 20th, 2008 01:13 AM
Dynamic table column sizing tomsi BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 February 1st, 2006 08:58 AM
Opening New Window p_nut33 Classic ASP Basics 1 August 6th, 2004 08:11 PM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
Opening New Window james_sellwood ASP.NET 1.0 and 1.1 Basics 5 June 12th, 2003 11:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.