469,344 Members | 6,565 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Passing an image name as an argument

Hi,

I would like to be able to open a web page and pass it the name of the picture that I want displayed. For example, the current line that displays the picture reads

<td width="762" bgcolor="#FFFFFF"><img src="165_6593.jpg" alt="" name="" width="760" height="570" border="0" /></td>

Each of the images that I want to display are the same size, so all I'm concerned with is being able to change the name of the image when I call the page. For example, if the page is called www.dandare.com and I want it to display the image dan.jpg then I'd like to call it using:
www.dandare.com?dan.jpg

dan.jpg would then be substituted for "165_6593.jpg"

This is probably easy, but I did my IT degree in 1990 when DOS was king!

Thanks in advance...
May 24 '07 #1
2 1386
iam_clint
1,208 Expert 1GB
put this at the bottom of your html page
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. window.onload = setImage();
  3. function setImage() {
  4. var theimg = document.getElementById("img1");
  5. var winloc = window.location.href;
  6. var qstring = winloc.split("?")[1];
  7. var qimg = qstring.split("=");
  8. if (qimg[0]=="img") { theimg.src = qimg[1]; }
  9. }
  10. </script>
  11.  

then try it out like this

http://www.wherever.com/whatever.htm?img=dan.jpg

or www.wherever.com?img=dan.jpg
May 24 '07 #2
Thanks- that's fantastic and worked first time!
May 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by domeceo | last post: by
7 posts views Thread by Harolds | last post: by
17 posts views Thread by Charles Sullivan | last post: by
4 posts views Thread by B Squared | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.