Hi,
I wrote a little bit of script that loads an image from a thumbnail when the
thumbnail is clicked.
It is not very clever, and I have found it only works in IE..
could someone have a look at the script below and suggest how I can make it
work in netscape too?
Steve
PS: very new to js!!
<script language="JavaS cript">
var imagePos = -1;
var imageStr = "<?=writeImageA rray() ?>"; //Assume this is loaded with a
string of image names separated by |
var imageArray = imageStr.split( "|");
function loadPreviousIma ge(){
imagePos--;
if (imagePos < 0){
imagePos = imageArray.leng th -1;
}
loadImage(image Pos);
}
function loadNextImage() {
imagePos++;
if( imagePos >= imageArray.leng th){
imagePos = 0;
}
loadImage(image Pos);
}
function loadImage(i){
document.all("I MAGEHOLDER").st yle.visibility = "hidden";
if( imageArray.leng th==0){
return;
}
imagePos = i;
var imagePath = imageArray[i].split("^")[0];
var imageAlt = imageArray[i].split("^")[1];
var imageW = imageArray[i].split("^")[2];
var imageH = imageArray[i].split("^")[3];
document.all("I MAGEHOLDER").sr c = imagePath;
document.all("I MAGEHOLDER").al t = imageAlt;
document.all("I MAGEHOLDER").wi dth = imageW;
document.all("I MAGEHOLDER").he ight = imageH;
document.all("I MAGEHOLDER").st yle.visibility = "visible";
document.all("C APTION").firstC hild.nodeValue = imageAlt;
}
</script> 6 1949
SPG wrote: Hi,
I wrote a little bit of script that loads an image from a thumbnail when the thumbnail is clicked. It is not very clever, and I have found it only works in IE..
could someone have a look at the script below and suggest how I can make it work in netscape too?
Stop writing IE proprietary code would be a start.
Steve
PS: very new to js!!
<script language="JavaS cript"> var imagePos = -1; var imageStr = "<?=writeImageA rray() ?>"; //Assume this is loaded with a string of image names separated by |
ummm, ok.
Instead of having the browser split it, why not have PHP generate the
appropriate JS code?
var imageArray = imageStr.split( "|");
function loadPreviousIma ge(){ imagePos--; if (imagePos < 0){ imagePos = imageArray.leng th -1; } loadImage(image Pos); } function loadNextImage() { imagePos++; if( imagePos >= imageArray.leng th){ imagePos = 0; } loadImage(image Pos); } function loadImage(i){ document.all("I MAGEHOLDER").st yle.visibility = "hidden";
document.all is an MSIE only (within limits) code practice.
document.images['IMAGEHOLDER'].style.visibili ty = "hidden";
assuming you have the style attribute on an img tag with name="IMAGEHOLD ER"
if( imageArray.leng th==0){ return; } imagePos = i; var imagePath = imageArray[i].split("^")[0]; var imageAlt = imageArray[i].split("^")[1]; var imageW = imageArray[i].split("^")[2]; var imageH = imageArray[i].split("^")[3]; document.all("I MAGEHOLDER").sr c = imagePath;
document.images['IMAGEHOLDER'].src = imgPath
document.all("I MAGEHOLDER").al t = imageAlt;
document.images['IMAGEHOLDER'].alt=imageAlt;
document.all("I MAGEHOLDER").wi dth = imageW;
document.images['IMAGEHOLDER'].width=imageW;
document.all("I MAGEHOLDER").he ight = imageH;
document.images['IMAGEHOLDER'].height = imageH;
document.all("I MAGEHOLDER").st yle.visibility = "visible";
document.images['IMAGEHOLDER'].style.visibili ty = "visible";
document.all("C APTION").firstC hild.nodeValue = imageAlt;
document.getEle mentByID('CAPTI ON').firstChild .nodeVAlue = imagAlt;
Assuming you have something like:
<div id="CAPTION">.. </div>
} </script>
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Hi Randy,
Thanks for this...
All seems to work fine except for
"Randy Webb" <Hi************ @aol.com> wrote in message
news:l6******** ************@co mcast.com... SPG wrote:
Hi,
I wrote a little bit of script that loads an image from a thumbnail when the thumbnail is clicked. It is not very clever, and I have found it only works in IE..
could someone have a look at the script below and suggest how I can make it work in netscape too?
Stop writing IE proprietary code would be a start.
Steve
PS: very new to js!!
<script language="JavaS cript"> var imagePos = -1; var imageStr = "<?=writeImageA rray() ?>"; //Assume this is loaded with a string of image names separated by |
ummm, ok. Instead of having the browser split it, why not have PHP generate the appropriate JS code?
var imageArray = imageStr.split( "|");
function loadPreviousIma ge(){ imagePos--; if (imagePos < 0){ imagePos = imageArray.leng th -1; } loadImage(image Pos); } function loadNextImage() { imagePos++; if( imagePos >= imageArray.leng th){ imagePos = 0; } loadImage(image Pos); } function loadImage(i){ document.all("I MAGEHOLDER").st yle.visibility = "hidden";
document.all is an MSIE only (within limits) code practice.
document.images['IMAGEHOLDER'].style.visibili ty = "hidden";
assuming you have the style attribute on an img tag with name="IMAGEHOLD ER"
if( imageArray.leng th==0){ return; } imagePos = i; var imagePath = imageArray[i].split("^")[0]; var imageAlt = imageArray[i].split("^")[1]; var imageW = imageArray[i].split("^")[2]; var imageH = imageArray[i].split("^")[3]; document.all("I MAGEHOLDER").sr c = imagePath;
document.images['IMAGEHOLDER'].src = imgPath
document.all("I MAGEHOLDER").al t = imageAlt;
document.images['IMAGEHOLDER'].alt=imageAlt;
document.all("I MAGEHOLDER").wi dth = imageW;
document.images['IMAGEHOLDER'].width=imageW;
document.all("I MAGEHOLDER").he ight = imageH;
document.images['IMAGEHOLDER'].height = imageH;
document.all("I MAGEHOLDER").st yle.visibility = "visible";
document.images['IMAGEHOLDER'].style.visibili ty = "visible";
document.all("C APTION").firstC hild.nodeValue = imageAlt;
document.getEle mentByID('CAPTI ON').firstChild .nodeVAlue = imagAlt;
Assuming you have something like: <div id="CAPTION">.. </div>
} </script>
-- Randy comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly Answer:It destroys the order of the conversation Question: Why? Answer: Top-Posting. Question: Whats the most annoying thing on Usenet?
Hi Randy,
Thanks for this, All seems to work fine except for this...
document.getEle mentByID('CAPTI ON').firstChild .nodeValue = imagAlt;
The "CAPTION" element is buried inside a teble cell like so..
.....some html....
<td colspan=2 ID="CAPTION_CEL L"><DIV ID="CAPTION">&n bsp;<DIV></td>
....some more!...
Not a show stopper if I cannot make that bit work, but would be nice!
Steve
"Randy Webb" <Hi************ @aol.com> wrote in message
news:l6******** ************@co mcast.com... SPG wrote:
Hi,
I wrote a little bit of script that loads an image from a thumbnail when the thumbnail is clicked. It is not very clever, and I have found it only works in IE..
could someone have a look at the script below and suggest how I can make it work in netscape too?
Stop writing IE proprietary code would be a start.
Steve
PS: very new to js!!
<script language="JavaS cript"> var imagePos = -1; var imageStr = "<?=writeImageA rray() ?>"; //Assume this is loaded with a string of image names separated by |
ummm, ok. Instead of having the browser split it, why not have PHP generate the appropriate JS code?
var imageArray = imageStr.split( "|");
function loadPreviousIma ge(){ imagePos--; if (imagePos < 0){ imagePos = imageArray.leng th -1; } loadImage(image Pos); } function loadNextImage() { imagePos++; if( imagePos >= imageArray.leng th){ imagePos = 0; } loadImage(image Pos); } function loadImage(i){ document.all("I MAGEHOLDER").st yle.visibility = "hidden";
document.all is an MSIE only (within limits) code practice.
document.images['IMAGEHOLDER'].style.visibili ty = "hidden";
assuming you have the style attribute on an img tag with name="IMAGEHOLD ER"
if( imageArray.leng th==0){ return; } imagePos = i; var imagePath = imageArray[i].split("^")[0]; var imageAlt = imageArray[i].split("^")[1]; var imageW = imageArray[i].split("^")[2]; var imageH = imageArray[i].split("^")[3]; document.all("I MAGEHOLDER").sr c = imagePath;
document.images['IMAGEHOLDER'].src = imgPath
document.all("I MAGEHOLDER").al t = imageAlt;
document.images['IMAGEHOLDER'].alt=imageAlt;
document.all("I MAGEHOLDER").wi dth = imageW;
document.images['IMAGEHOLDER'].width=imageW;
document.all("I MAGEHOLDER").he ight = imageH;
document.images['IMAGEHOLDER'].height = imageH;
document.all("I MAGEHOLDER").st yle.visibility = "visible";
document.images['IMAGEHOLDER'].style.visibili ty = "visible";
document.all("C APTION").firstC hild.nodeValue = imageAlt;
document.getEle mentByID('CAPTI ON').firstChild .nodeVAlue = imagAlt;
Assuming you have something like: <div id="CAPTION">.. </div>
} </script>
-- Randy comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly Answer:It destroys the order of the conversation Question: Why? Answer: Top-Posting. Question: Whats the most annoying thing on Usenet?
SPG wrote: Hi Randy,
Thanks for this, All seems to work fine except for this...
document.getEle mentByID('CAPTI ON').firstChild .nodeValue = imagAlt;
The "CAPTION" element is buried inside a teble cell like so..
.....some html.... <td colspan=2 ID="CAPTION_CEL L"><DIV ID="CAPTION">&n bsp;<DIV></td> ....some more!...
Not a show stopper if I cannot make that bit work, but would be nice!
document.getEle mentByID('CAPTI ON').innerHTML = imageAlt;
But it should have complained that imagAlt was undefined since I made a
typo in replying to you. Read the Group FAQ, DynWrite specifically, on
changing the contents of a DIV tag. Also read my signature (along with
the FAQ) with regards to top-posting.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
"Randy Webb" <Hi************ @aol.com> wrote in message
news:O-*************** *****@comcast.c om... SPG wrote: Hi Randy,
Thanks for this, All seems to work fine except for this...
document.getEle mentByID('CAPTI ON').firstChild .nodeValue = imagAlt;
The "CAPTION" element is buried inside a teble cell like so..
.....some html.... <td colspan=2 ID="CAPTION_CEL L"><DIV ID="CAPTION">&n bsp;<DIV></td> ....some more!...
Not a show stopper if I cannot make that bit work, but would be nice!
document.getEle mentByID('CAPTI ON').innerHTML = imageAlt;
But it should have complained that imagAlt was undefined since I made a typo in replying to you. Read the Group FAQ, DynWrite specifically, on changing the contents of a DIV tag. Also read my signature (along with the FAQ) with regards to top-posting.
-- Randy comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly Answer:It destroys the order of the conversation Question: Why? Answer: Top-Posting. Question: Whats the most annoying thing on Usenet?
Hi Randy
Thanks for that.. it works of course. (I managed the typo myself previously)
As for top-posting.. My apologies. Wrists are slapped!
Thanks for the help!
Steve
SPG wrote:
[...] } function loadImage(i){ document.all("I MAGEHOLDER").st yle.visibility = "hidden"; if( imageArray.leng th==0){ return; } imagePos = i;
Without prejudice to anything Randy posted, I think the
following can be tidied up thusly:
var imagePath = imageArray[i].split("^")[0]; var imageAlt = imageArray[i].split("^")[1]; var imageW = imageArray[i].split("^")[2]; var imageH = imageArray[i].split("^")[3]; document.all("I MAGEHOLDER").sr c = imagePath; document.all("I MAGEHOLDER").al t = imageAlt; document.all("I MAGEHOLDER").wi dth = imageW; document.all("I MAGEHOLDER").he ight = imageH; document.all("I MAGEHOLDER").st yle.visibility = "visible";
var imgA = imageArray[i].split("^");
var iHolder = document.images['IMAGEHOLDER'];
iHolder.src = imgA[0];
iHolder.alt = imgA[1];
iHolder.width = imgA[2];
iHolder.height = imgA[3];
iHolder.style.v isibility = "visible";
That's gotta save a few clock cycles...
--
Fred This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Henning Vestergaard Poulsen |
last post by:
Hi, I have a problem that I hope someone can help me with.
I'm building a web page with pictures I've taken with my digital camera. I
have succeded making a javacript that, when clicking on a thumbnail, it
changes the main image.
Now, I would like to put an explanation (and date and some EXIF-info) to
each photo so some text is shown next to the main photo when loaded.
I don't know how to change the text without reloading the whole...
|
by: antishok |
last post by:
Hi,
I'm writing a page which has a somewhat similar folder tree to that of
the windows explorer, where each folder is made of a <SPAN> tag
consisting of the folder image (closed or open) and the folder name.
When certain actions are performed by the user, more folders (spans)
are dynamically added using javascript function appendChild().
I add a new folder span to a container span which holds the whole
tree.
|
by: C A Upsdell |
last post by:
I have a site where I am setting a style dynamically, using the JS
statement:
obj.style.backgroundImage = 'url(img/bak_page.jpg)';
where 'obj' is either document.getElementById(id), or document.all,
depending on browser support.
This works just fine, with just one small problem: I want to set the style
ONLY for screen media, not for printer media; the above statement appears to
|
by: Nicholas Couch |
last post by:
I have a little form with a couple of dynamically generated list
boxes. When the user makes a selection from the first box, the second
box is refreshed. When they make a selection from the second box, I
concatenate the selections from the two boxes and add the string to a
list at the top of the form, using createElement and appendChild. The
list is actually a bunch of span elements contained within a div. Each
span element includes a small...
|
by: Thomas |
last post by:
Hi,
I'm having a problem with the dynamically created inputfields in
Internet Explorer.
The situation is the following:
- I have a dynamically created table with a textbox in each Cell.
- It is possible to Add and Delete rows
- Some cells have special attributes (readonly and events)
Here's a snippet of the code:
| |
by: Donald Xie |
last post by:
Hi,
I noticed an interesting effect when working with controls that are
dynamically loaded. For instance, on a web form with a PlaceHolder control
named ImageHolder, I dynamically add an image button at runtime:
//----- Code snippet
protected System.Web.UI.WebControls.PlaceHolder ImageHolder;
private void Page_Load(object sender, System.EventArgs e)
|
by: max |
last post by:
Hello,
Based on various posts, I've come up with the following code to load
data into a js array dynamically without a screen refresh. It works,
but you have to push the button twice before it shows the new data that
you have changed in the js file. It's almost like something is being
cached. Can anyone help? Following is the code from the php and js
file:
test.php
|
by: GaryB |
last post by:
Hi Guys,
I've been battling with this one for hours - I hope that you can help
me!
My code modifies the <aon a page, from a standard document link into
a link with a tailored onclick event.
It works perfectly (assigning the correct images and the correct
onclick events to the correct <atags):
|
by: miladhatam |
last post by:
can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |