Passing params to JS file implemented inside a php file

V

vdfvdfv

Hi Guys,
I have a dynamic JS file created by a php file
I call this script using:
<script type="text/javascript" src="http://www.mysite.com/jsfile.php?
keyword=xxx"></script>
Is it possible to somehow change the keyword xxx using javascript?
(i.e. create it dynamically)
Thanks
 
V

vdfvdfv

vdfvdfv said the following on 11/14/2007 8:37 PM:


Yes. And how you do it depends on what you are trying to do.

Are you wanting to simply reload that file with a different keyword,
without reloading the page, or something else?
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Suppose I want to get the page title and pass it as a param.
Is it possible?
Thanks
(e-mail address removed)
 
M

mic123

vdfvdfv said the following on 11/14/2007 9:19 PM:







Yes. And how you do it depends on what you are trying to do.

Are you wanting to simply reload that file with a different keyword,
without reloading the page, or something else?

For some reason, I think I have already said/asked that before.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -

Hi Randy,
I don't need to reload anything, I will have this js/php code in
several webpages (code= <script type="text/javascript" src="http://
www.mysite.com/jsfile.php?keyword=xxx"></script> )
In each webpage I want to take the page title, do some string
processing in a local javascript function, then pass it as a param to
the js/php script
i.e. I want the parameter keyword to be dynamic, instead of being XXX.
It is obvious how i can implement it with PHP/ASP, but not with
javascript.
Any help would be appreciated
 
M

mic123

(e-mail address removed) said the following on 11/15/2007 12:18 AM:







Since you have PHP available to you, use it.


That is easier done in PHP than in JS.


Two ways:

1) Load that file dynamically instead of hard coding it.
2) Pass the parameter to a function in the file and then act on it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -

I don't have PHP available to me, since there are things I can only
know on the client side using javascript (like client browser height/
width)

i cannot know the final params until after the page was loaded so I
have to somehow set the params using javascript.

When you're saying I should load the php file (which contains the JS
code) dynamically you mean I should use ajax or is there another way
to do it?
 
M

mic123

(e-mail address removed) said the following on 11/17/2007 7:20 PM:








Re-write your PHP generated JS file to handle them after the page loads.
Short of that, dynamically create the SCRIPT element and load it after
the page loads. Search the archives for loadJSFile and start reading.


No, not some buzzword like AJAX. Use a more reliable method. Search for
my name and "loadJSFile" in the archives. You can find out how to load a
JS File - dynamically - after the page has finished loading.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -

Googling that as we speak.
Thank you.
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top