JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old December 16th, 2004, 09:18 AM
Potsie Potsie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 Potsie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Help with getWidth()

Helpless newbie here. I am trying to open a new window, sized appropriately to hold either a portrait or landscape oriented image. For this I need to know the width of the new image before I open the window.

I'm pretty clueless, but this seemed to me to be the simplest way to do this:

var img = new Image("http://helma.org/images/hop.gif");
var w = img.getWidth();
newwindow=window.open('','jav','width=w,height=100 ");

Opening the window is no problem, but getting the width of the image is. Any help? I'm trying to keep this simple. Do I have to load the image first? If so how? Do I need to create a class? If so, I am clueless. I have searched out a million references to the getWidth() function but there are no simple examples of this use.

Reply With Quote
  #2  
Old December 16th, 2004, 10:08 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Quote:
myImage = new Image();
myImage.src = "conference.jpg";
newwindow=window.open(myImage.src,'jav','width='+m yImage.width.toString()+',height='+myImage.height. toString());


Does that help at all?

Reply With Quote
  #3  
Old December 16th, 2004, 10:10 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Um, ignore the spaces in myImage.width.toString()

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Help with getWidth()


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway