Someone here may know how to do this. I have a webpage which has a few javascript functions associated with it to do different things. Now I want to know if it is possible to provide a link to the page and invoke one of these functions with parameters. can this be done?
let's say the site is www.blahblahblah.com/simplepage.html
and the function is called myTestFunction(number)
I can set up links on the simplepage.html file using a href's with the link javascript:myTestFunction(1) for example but how would I do this in one foul swoop letting someone go directly to the function without clicking on the link on the page?
Cheers
let's say the site is www.blahblahblah.com/simplepage.html
and the function is called myTestFunction(number)
I can set up links on the simplepage.html file using a href's with the link javascript:myTestFunction(1) for example but how would I do this in one foul swoop letting someone go directly to the function without clicking on the link on the page?
Cheers
Posté Thu 21 Feb 08 @ 6:19 am
In the BODY statement, add an attribute called "onLoad".
Here you can find a lot of information: http://www.htmlcodetutorial.com/document/_BODY_onLoad.html
Here you can find a lot of information: http://www.htmlcodetutorial.com/document/_BODY_onLoad.html
Posté Thu 21 Feb 08 @ 7:53 am
Thanks for that but I don't believe it will achieve precisely what I need to achieve. I already use the onload attribute to fire off another function which loads up an XML file that I need on my site. I specifically need to be able to make my site load up and then execute a function. Perhaps this is a case for a CGI script which accepts parameters then calls a JS function with those parameters. I haven't done this before so if anyone has any good resources please post a link here. Thanks.
Posté Thu 21 Feb 08 @ 12:43 pm
What exactly are you trying to acheive?
- Auto redirect to new page ? (set new header)
- Auto update of page ? (HTMLRequest)
- Auto trigger a function on the page?`(OnLoad)
Posté Thu 21 Feb 08 @ 2:52 pm
I am trying to make someone go to the webpage and depending on parameters they (optionally) pass as part of the URL I would like a Javascript function to change the content of the page. Currently when I load the webpage I fire off a load XML Javascript function and if users click certain links on the page then Javascript functions change the content by looking up the XML document and displaying the appropriate information to the user. This works well but I would like to be able to give someone a link to do directly to certain content (behind the scenes the function(s) would be performing the page update)
Posté Fri 22 Feb 08 @ 4:16 am
If the parameters are set in the URL a simple IF statement should do (if I understand you correct)
Say your URL is
www.mysite.com/home.php?value=x
Then a simple $_GET['value'] would get the parameter, and a statement IF ( value=X) THEN execude code logic should do
But you seem to know java and XML better than me, so not sure I can help much
Say your URL is
www.mysite.com/home.php?value=x
Then a simple $_GET['value'] would get the parameter, and a statement IF ( value=X) THEN execude code logic should do
But you seem to know java and XML better than me, so not sure I can help much
Posté Fri 22 Feb 08 @ 10:28 am
I cannot use PHP with my ISP but I think I may be onto something based on what you recommend. I may well achieve the desired result using CGI/Perl which is allowed by my ISP. Thanks for the suggestion.
Posté Mon 03 Mar 08 @ 2:58 pm