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.

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).

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
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.