Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send a string to another page e.g. simple online photo almbum

Sending data between pages

How to send a string to another page e.g. simple online photo almbum

by  danbhala  Posted    (Edited  )
page1.html

<a href="page 2.html#PassedInformation">Link</a>

page2.html

this code brabs the information after the '#' charecter:
var loc=document.location.href;
var information=loc.substring(loc.indexOf("#")+1,loc.length);

this is very handy to create a template page used for photographs etc..
i.e.

Page1.html
<a href="page 2.html#Pic1">Link to Pic1</a>
<a href="page 2.html#Pic2">Link to Pic2</a>
<a href="page 2.html#Pic3">Link to Pic3</a>

Page2.html
var loc=document.location.href;
var PicName=loc.substring(loc.indexOf("#")+1,loc.length);

and in the body of page2.html:
document.write("<img src=img/"+PicName+".jpg>");

Basically you dont have to make like about 50 individual pages for your online photo album. all ya gotta do is name your pics Pic1.jpg, Pic2.jpg, Pic3.jpg etc...


-dan =)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top