I know I asked this awhile ago but I can’t find the page I used it in now… nor can I find the thread I stated the question in…. I need a bit of script that will change the size of a picture according to resolution
[url=http://www.webapplikations.com/pages/html_js/image_examples/ResizeImageOnResize.html]Resource Here[/url] [/B][/QUOTE] Doesn't help.. I need something that works with the screen resolution.. not the window resolution
</script>[/code]This will write an image height and width 1/5 size of max screen height and width (which are often a tad more than actual resolution)
Of course, if the user changes resolution while viewing your page, there will be no change in size until page refreshed. [/B][/QUOTE] I need it so I can specify how big the picture while be at a certain resolution... >_<
@steelersfan88Mar 20.2004 — #something like an array of screen heights and widths? Like:[code=php]<script type="text/javascript">
var screenW = screen.width var screenH = screen.height
var toWidth = -1 var toHeight = -1
var maxH = 600 // height/width if resolution is greater var maxW = 600 // than those given in the array
/**************************************
* Change all height and widths here * The screen is the possible height/width of the screen * The img is the height/width of the image at that or a smaller resolution * Keep all resolutions in ascending order, smaller at top!
**************************************/
var heights = new Array heights[0] = {screen:"600",img:"250"} heights[1] = {screen:"768",img:"350"} heights[2] = {screen:"864",img:"500"}
var widths = new Array widths[0] = {screen:"800",img:"250"} widths[1] = {screen:"1024",img:"350"} widths[2] = {screen:"1152",img:"500"}
@Khalid_AliMar 20.2004 — #[i]Originally posted by sorrowfulkiller [/i]
[B]Doesn't help.. [/B][/QUOTE] in that I ma sure you are one of those who will not want to think at all and I am sure even what steelers posted the second time, that won't work for you...
The purpose here is usally to guide a member in a right direction,not to give 100 % customised solution for your problem( though I know that we all,volunteers here, if we have time,tend to do that).
[B]something like an array of screen heights and widths? Like:[code=php]<script type="text/javascript">
var screenW = screen.width var screenH = screen.height
var toWidth = -1 var toHeight = -1
var maxH = 600 // height/width if resolution is greater var maxW = 600 // than those given in the array
/**************************************
* Change all height and widths here * The screen is the possible height/width of the screen * The img is the height/width of the image at that or a smaller resolution * Keep all resolutions in ascending order, smaller at top!
**************************************/
var heights = new Array heights[0] = {screen:"600",img:"250"} heights[1] = {screen:"768",img:"350"} heights[2] = {screen:"864",img:"500"}
var widths = new Array widths[0] = {screen:"800",img:"250"} widths[1] = {screen:"1024",img:"350"} widths[2] = {screen:"1152",img:"500"}
if(toHeight < 0) { // picture bigger than given resolutions picH = maxH } else { picH = heights[toHeight].img }
if(toWidth < 0) { // picture bigger than given resolutions picW = maxW } else { picW = heights[toWidth].img }
/*** DO NOT EDIT ABOVE THIS LINE ***/
// Change the src of the image and alt text only document.write("<img src='myPic.jpg' alt='my pic' height="+ picH +" width="+ picW +">")
</script>[/PhP]The script can probably be condensed, i tried to comment somewhat and put a little bit of spacing to improve legibility. [/B][/QUOTE] Exactly what I was looking for, thanks...
btw Khalid Ali, I'm fairly new to javascript and I don't really know how I would've done something like this...
@Khalid_AliMar 20.2004 — #[i]Originally posted by sorrowfulkiller [/i]
[B]
btw Khalid Ali, I'm fairly new to javascript [/B][/QUOTE] fair enough,pardon my little rant above,its that soe times there are people who will not want to learn rather try to get the complete solution..Glad you got your help here..:-)
[B]fair enough,pardon my little rant above,its that soe times there are people who will not want to learn rather try to get the complete solution..Glad you got your help here..:-) [/B][/QUOTE] I know exactly what you mean... They don't want to learn it for themselves so they just ask people how to do it... it bugs the hell out of me... >_<