0

I'm struggling with this Javascript:

 width = screen.width * .75;
 height = screen.height * .75;
$(".colorbox").colorbox({
 width:"800px", 
 height:"600px", 
 iframe:true, 
 scrolling:false});

I am trying to put the values of width and height into the 800 and 600 spots, respectively.

Aaron Yodaiken
19.7k33 gold badges110 silver badges189 bronze badges
asked Aug 15, 2011 at 4:35

2 Answers 2

3

This is pretty straightforward to fix:

var width = screen.width * .75; 
var height = screen.height * .75;
$(".colorbox").colorbox({
 width: width, 
 height: height, 
 iframe: true, 
 scrolling: false});

(Just a side note, put var before your variable declarations, or else they will become global, perhaps unintentionally).

answered Aug 15, 2011 at 4:39
Sign up to request clarification or add additional context in comments.

2 Comments

+1 but pretty please suggest the use of var and that globals are bad, etc. ;)
Or just width: screen.width * 0.75; etc. to avoid the possibility of globals completely.
1

Colorbox actually supports specifying the widths as integers or with a unit..

So,

$(".colobox").colorbox({
 "width": width,
 "height": height
});
answered Aug 15, 2011 at 4:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.