html - javascript $(window).width() property not working in in Internet Explorer -


i've following div absolute position:

<div id="target" style="height: 300px; position: absolute; top: 275px;"></div> 

what doing calculating screen horizontal resolution using javascript , using obtained width, calculating width , left position of "target" div follows:

var windowwidth = $(window).width(); var targetwidth = windowwidth * 0.7; var targetleftpos = windowwidth * (15 / 100); $('#target').css({ 'width': targetwidth }); $('#target').css({ 'left': targetleftpos }); 

this code working in browsers in ie code not working @ causing target div not having width , left position style, causing designing destructed.

is there way detect clients browser , alternate code if detected browser ie.

please tell me how should detect clients browser , alternate code should execute ie.

thanks in advance.

instead of $(window).width, use

var windowwidth = window.innerwidth; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -