From one click, follow a link and then run javascript on that page?

T

thenewlook

Hello,

Is it possible that by clicking on a hyperlink, the new webpage is
displayed and at the same time, javascript is also run on that page?
I am implementing a slideshow photo album. On page A (image index), I
have a hyperlink to Page B (first image). On Page B, I have a
javascript to run a slideshow (through a button).
What I want is that when the user clicks on the hyperlink from Page A,
the Page B is displayed and the javascript code also runs so that they
directly see the slideshow instead of clicking on the button.

Any help will be appreciated.
Thanks in advance.
 
J

Jon Spivey

Hi,
You'd run the javascript in body onload on Page B, ie
<body onload="RunSlideShow();">

Cheers,
Jon
Microsoft MVP
 
M

MD Websunlimited

Hi,

Use the onload event of the body tag to cause a click at the button.

Assuming the button is a submit button in a form then

<body onload="form2.submit();" >
 
T

thenewlook

Thanks to all for the responses.
Using the onload or putting the call to the function in the body tag
would always kick in the function whenever the page is loaded. I want
it to happen only when the user gets to it from Page A. There could be
another Page C with a hyperlink to Page B. I don't want the javascript
to run when the user gets to Page B from page C.
Is that possible?

Thanks,
-Ritesh
 
J

Jon Spivey

check the referer, eg
if(location.referer.indexOf("pagea.htm")>0){
// do stuff
}

Cheers,
Jon
Microsoft MVP - FP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top