登录:     


Forum: General Discussion

Topic: HTML - Javascript - Link question

由于该帖子已年深日久,可能包含陈旧过时或描述错误的信息。

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
 

发表时间 Thu 21 Feb 08 @ 6:19 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.
 


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)
 

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)
 

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
 

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.
 



(陈旧帖子或论坛版块会自动关闭)