/    Sign up×
Community /Pin to ProfileBookmark

Showing a picture in a new window…

I have a javascript function for displaying an image in a new window

However, I have to tell the function the exact size of the image

Is there some way it can work out the size of the image automatically?

[code]<script language=”JavaScript” type=”text/JavaScript”>
<!–
function ShowPicture(picURL, width, height){

var leftVal = (screen.width-width) / 2;
var topVal = (screen.height-height) / 2;

newWindow=window.open(‘picURL’,’newWin’,’toolbar=no,width=’+width+’,height=’+height+’,left=’+leftVal+’,top=’+topVal)
newWindow.document.write(‘<html><head></head><body topmargin=”0″ leftmargin=”0″ rightmargin=”0″ bottommargin=”0″><img src=”‘+picURL+'”></body></html>’)
newWindow.focus()
}
//–>
</script>
[/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoNov 09.2005 — Preload the images into an array and then check them for their heights and widths.
Copy linkTweet thisAlerts:
@cusimar9authorNov 09.2005 — Erm... how would I do this?
Copy linkTweet thisAlerts:
@cusimar9authorNov 09.2005 — Thanks! ?
×

Success!

Help @cusimar9 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.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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