PDA

View Full Version : Multi Script errors (expected char, object not supported)



trigger
02-12-2010, 11:35 AM
Hey,

I've got some script from varies places played with it, added me own bits and such (first time working with JS by the way) so that a webpage will detect the screen resolution and change the page accordingly for the activdesktop at the school i work at.


First it told me that I needed to add a ";" (highlighted in red), aha simple I thought, I added the semi colon where it said to do.

Now it's telling me that the object doesn't support this action. I've been goin around and around like this for the past few days and have now decided that I shall have to durrender and ask for help.

I know this will be something rather simple that I have missed and shall no doubt kick myself when someone solves it.




<script type="text/javascript">
<!--
if (screen.width <= 1024) {
window.location = '1024x768.html';
}

else if (screen.width <= 1280) {
window.location = '1280x1024.html';
}

else if (screen.width <= 1440); {
window.location = '1440x900.html';
}

else { window.location='index2.html';
}
//-->
</script>

Nile
02-12-2010, 12:47 PM
This should work:


<script type="text/javascript">
<!--
if (screen.width <= 1024) {
window.location = '1024x768.html';
} else if (screen.width <= 1280) {
window.location = '1280x1024.html';
} else if (screen.width <= 1440) {
window.location = '1440x900.html';
} else {
window.location='index2.html';
}
//-->
</script>

trigger
02-12-2010, 01:53 PM
No joy I'm afraid, cheers for trying.

Well in one way it worked, no more error messages, now the page just crashes, it refuses to load at all.

Have I got the "window.location" part wrong maybe? I know theres a few ways of getting it to point to a file but that seemed the most common?

Nile
02-12-2010, 08:29 PM
It seems to work for me. Mind putting an online example?

trigger
02-16-2010, 01:04 PM
Managed toget a moment to put it online. All it does for me is crash so not sure how much use it will be to you. Wondeirng if it's something to do with the school network. Here's the link

http://www.hornsea.eriding.net/wall/1024x768demo.html

Cheers

Nile
02-16-2010, 01:10 PM
It redirected me to: http://www.hornsea.eriding.net/wall/1280x1024.html =/ Same in IE (7 and 8), Safari, Chrome, and Opera.

trigger
02-16-2010, 01:14 PM
Ah right so its something to do with the network. Thanks very much! Like I said, knew it would be something stupid :P