/    Sign up×
Community /Pin to ProfileBookmark

Popup sized by Image size

The correct is:

How I can set the size of a popup window with the size (width and height) of an image?

Thanks again.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@dabushFeb 26.2003 — lets say the width of the img is called [I]imgwidth[/I] and height of the img is called [I]imgheight[/I].

[B]open("url.html","windowname","width=imgwidth,height=imgheight");[/B]
Copy linkTweet thisAlerts:
@gportellaauthorFeb 26.2003 — [i]Originally posted by dabush [/i]

[B]lets say the width of the img is called [I]imgwidth[/I] and height of the img is called [I]imgheight[/I].



[B]open("url.html","windowname","width=imgwidth,height=imgheight");[/B] [/B]
[/QUOTE]


Ok, but the really thing goes like:

1 - I will create an instance of an image object;

2 - Then I will load the image into the src property of the object;

3 - HOW I GET THE IMAGE SIZE USING THE IMAGE OBJECT CREATED ?

This is the question, sorry if i wasn't clear.

thanks.
Copy linkTweet thisAlerts:
@khalidali63Feb 26.2003 — var img = new Image();

img.src = "someImage.gif"

X = img.width

Y = img.height;


Hope this helps

Cheers

Khalid
Copy linkTweet thisAlerts:
@gportellaauthorFeb 26.2003 — [i]Originally posted by khalidali63 [/i]

[B]var img = new Image();

img.src = "someImage.gif"



X = img.width

Y = img.height;





Hope this helps



Cheers



Khalid [/B]

[/QUOTE]

===========================================

Ok, this works and now i will give you a problem that came,

my script goes below:

function Ampliar(arquivo) {

titulo = "Posto Planalto";

var img_src = new Image;

img_src.src = arquivo;

img_w = img_src.width;

img_h = img_src.height;

var wdoc = window.open("", "Fotos", "toolbar=0,menubar=0,statusbar=0,location=0,height=" + img_h + ",width=" + img_w);

wdoc.document.open();

wdoc.document.write("<html><head><title>" + titulo + "</title></head>");

wdoc.document.write("<body leftmargin='0' topmargin='0'>");

wdoc.document.write("<img src='" + img_src.src + "' width='" + img_w + "' height='" + img_h + "'></img>");

wdoc.document.write("</body></html>");

wdoc.document.close();

}

the problems is that when the script is running and i click in an image the popup window open in the top of the screen and with a size that is not the image size and to complete the bug the image doesn't apear.
×

Success!

Help @gportella spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...