 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Jazeker
Joined: 12 Feb 2005 Posts: 2
|
Posted: Sat Feb 12, 2005 12:31 pm image resize... conditional |
|
|
|
Hi,
Wondering whether there's a simple html trick that can help me : I have a page with an image. The image should just show at it's original size, unless it 's bigger than the browser screen... in that case it should be resized to fit the window again.
Is there a way to let html do this ? If not, is there some simple javascript that does such things ?
thx |
|
chrisxkelley
Joined: 07 Dec 2004 Posts: 246
|
Posted: Sat Feb 12, 2005 12:56 pm |
|
|
|
there is no way to do this using html...
however, you can build in javascript a sniffer that detects the page size, then based on that redirects them to a page that will fit their resolution. It's kind of a painful way of getting around that problem, because you would have to make 3 different websites with different sizes.... if you dont want to do that just make your page compatible for 1024x768 and most people wont have a problem with it.
but if you want that javascript code let me know, its not too hard to write |
|
Jazeker
Joined: 12 Feb 2005 Posts: 2
|
Posted: Sun Feb 13, 2005 7:20 am |
|
|
|
| chrisxkelley wrote: |
there is no way to do this using html...
however, you can build in javascript a sniffer that detects the page size, then based on that redirects them to a page that will fit their resolution. It's kind of a painful way of getting around that problem, because you would have to make 3 different websites with different sizes.... if you dont want to do that just make your page compatible for 1024x768 and most people wont have a problem with it.
but if you want that javascript code let me know, its not too hard to write |
Hey chrisxkelley,
You would do me a big favour with such code. I hope it's very cross-browser compatible though. It is not a problem to let the JS call another page, because in fact, the page will be generated by a Perl/CGI script (now that's my area ) which can generate a new page where the image has a width = "100%" property or something like that. The problem is that when I do that right away, small images would be blown up and that would look terrible... hence the need to check when images are way out of line. |
|
chrisxkelley
Joined: 07 Dec 2004 Posts: 246
|
Posted: Mon Feb 14, 2005 11:22 pm |
|
|
|
sure... do something like this...
| Code: |
<script language="text/javascript">
<!--
if(screen.width>=1280||screen.height>=1024){
var sTargetURL = "bigscreen.html";
}else if(screen.width=1024||screen.height=768){
var sTargetURL = "normalscreen.html";
}else if (scren.width<=800||screen.height<=600){
var sTargetURL = "smallscreen.html";
}else{
var sTargetURL = "normalscreen.html";
alert("Your current resolution settings do not match the content of this page. Your current resolution is "+screen.width+" by "+screen.height+". If possible please change your resolution to either 800x600, 1024x768, or 1280x1024.");
}
function doRedirect()
{
setTimeout( "window.location.href = sTargetURL", 500 );
}
//-->
</script>
<body onload="doRedirect()">
|
if i got all that correctly, what it should do is check the resolution, if it is 1280x1024 or higher, it will redirect to bigscreen.html. if it is 1024x768, normalscreen.html, and if equal to or less than 800x600, smallscreen.html. If the user has a resolution somewhere in-between those three then it will politeley send an alert telling them that their resolution is different than what is best for the page, and ask them to change to one of the three choices.
what you need to do, is make those three pages, and put the function "doRedirect()" in the onLoad of your body tag.
phew. forgive me if i screwed up, it's 11:30 and i'm taking a break from my algebra 2 homework ...haha
cheers,
chris |
|
chrisxkelley
Joined: 07 Dec 2004 Posts: 246
|
Posted: Mon Feb 14, 2005 11:28 pm |
|
|
|
aso, i forgot to mention that if the user has wierd screen resolution, the page it will take them to is the one meant for 1024x768, but this can be changed easily.
and i'm moving this topic to the "other lnguages forum"  |
|
Talonkarrde
Joined: 19 Feb 2005 Posts: 1
|
Posted: Sat Feb 19, 2005 8:04 am |
|
|
|
Muchos helpful.
So the question is:
Suppose I have a website, and the first thing that loads is index.html.
I guess the script should go in index.html, and then I would have smallindex.html, bigindex.html, and normalindex.html, as three sites that basically have the same thing; but are formatted differently?
The 3 indecies only have lines of frame coding, so that would work, correct? |
|
optikool
Joined: 31 May 2005 Posts: 1 Location: Bay Area California
|
Posted: Tue May 31, 2005 11:10 am image resize... conditional |
|
|
|
Hi 1 other thing you can try is.... if all you want to do is resize an image that you placed on your web site, like for example a picture of your cat, you can go into your Web browser options and make sure Enable Automatic Resizing is checked. You probably don't want to have the size pre specified in your html code.
Hope that helps... |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|