Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Basic Image Positioning

Reply
Thread Tools

Basic Image Positioning

 
 
John Leeke
Guest
Posts: n/a
 
      10-23-2004
How are images positioned on a page?

In particular, how do I adapt the following javascript code:

**********
<img src="officecam0000.jpg" name="myImageName">
<script language="JavaScript">
function reloadImage() {
var now = new Date();
if (document.images) {
document.images.myImageName.src = 'officecam0000.jpg?' +
now.getTime();
}
setTimeout('reloadImage()',10000);
}
setTimeout('reloadImage()',10000);
</script>
**********

so that it positions and sizes the image the same as this html code:

**********
<p align="left"><img border="0" src="officecam0000.jpg" width="150"
height="130"><br>
OfficeCam(10sec.update)</p>
**********

I am new to javascript, so you may have to spell it out for me.

Thanks for your help.

John

 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      10-25-2004
John Leeke wrote:

> How are images positioned on a page?


They are positioned according to HTML layout standards... that is, an
image appears inside inline elements inline and if placed in a block
element will be separated from other block elements according to the
default CSS of the specific HTML elements in a particular browser.

So you can test:

<!-- block test -->
Test
<div><img ...></div>
Test

<!-- inline test -->
Test
<span><img ...></div>
Test

> In particular, how do I adapt the following javascript code:
>
> **********
> <img src="officecam0000.jpg" name="myImageName">


Drop this.

> <script language="JavaScript">


<script type="text/javascript">

> function reloadImage() {
> var now = new Date();
> if (document.images) {
> document.images.myImageName.src = 'officecam0000.jpg?' +
> now.getTime();
> }
> setTimeout('reloadImage()',10000);
> }
> setTimeout('reloadImage()',10000);


Move this to <body onload="setTimeout('reloadImage()',10000);">

> </script>


This script does no "positioning" of the image, it simply attempts to
guarantee (assuming client-side JavaScript) a fresh copy of the image
gets loaded into the user agent approximately every 10 seconds.

> **********
>
> so that it positions and sizes the image the same as this html code:
>
> **********
> <p align="left"><img border="0" src="officecam0000.jpg" width="150"
> height="130"><br>
> OfficeCam(10sec.update)</p>
> **********
>
> I am new to javascript, so you may have to spell it out for me.


<head>
<title>...</title>
<script type="text/javascript">
function reloadImage() {
if (document.images) {
document.images['myImageName'].src =
'officecam0000.jpg?' + (+new Date());
}
var t = setTimeout('reloadImage()', 10000);
}
</script>
</head>
<body onload="setTimeout('reloadImage()', 10000);">
<img name="myImageName"
border="0" src="officecam0000.jpg"
width="150" height="130">
<br>
OfficeCam (10 second update)</p>
</body>

--
Grant Wagner <(E-Mail Removed)>
comp.lang.javascript FAQ - http://jibbering.com/faq

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Positioning Jerry Camel ASP .Net 5 10-12-2005 07:42 PM
Basic CSS positioning Question?? Spartanicus HTML 11 09-06-2004 04:58 AM
positioning image slices CSS-style bulge HTML 8 07-19-2004 12:15 PM
help request: css positioning & text bg scalable image Ilya HTML 9 06-30-2004 02:24 PM
Image positioning. ftgow HTML 1 06-10-2004 02:37 AM



Advertisments