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

  • Thread starter Thread starter thenewlook
  • Start date Start date
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.
 
Hi,
You'd run the javascript in body onload on Page B, ie
<body onload="RunSlideShow();">

Cheers,
Jon
Microsoft MVP
 
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();" >
 
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
 
check the referer, eg
if(location.referer.indexOf("pagea.htm")>0){
// do stuff
}

Cheers,
Jon
Microsoft MVP - FP
 
Back
Top