So i have the following script that basically adjust the position of an element on the screen.
it works perfectly on the other browsers but cause an error on IE8
Here is the whole function call that causes the problem
function ajax_load(){
var screenwidth = window.innerWidth
var screenheight = window.innerHeight;
var current_width = 250;
var current_height = 70;
var left = (screenwidth - current_width)/2;
var bottom = (screenheight - current_height)/2;
var secondajaxloaderElement = document.getElementById('ajax_loader');
secondajaxloaderElement.style.bottom = bottom + 'px'; // Line 308 - problematic line
secondajaxloaderElement.style.left = left + 'px';
}
Any idea why would this fail on IE ?
The error i get from developer tool is : Invalid argument. and a line number(308) which point to secondajaxloaderElement.style.bottom = bottom + 'px';
Thoses are not supported in IE8:
var screenwidth = window.innerWidth
var screenheight = window.innerHeight;
http://www.w3schools.com/jsref/prop_win_innerheight.asp
See this post :
window.innerHeight ie8 alternative
This should work in IE8:
var screenwidth = document.body.clientWidth;
var screenheight = document.body.clientHeight;
Or you could also use jQuery with :
var screenwidth = $(window).width;
var screenheight = $(window).height;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.