Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables By URL parameters

Status
Not open for further replies.

j4606

MIS
Nov 28, 2005
349
US
Hi Guys, I remember a post about passing url parameters to javascript src. For example
Code:
<script type="text/javascript" src="javascript.js?parameter=value"></script>

I forgot how to access the parameter and value? Anyone have an idea of how I can accomplish this? Thanks!
 
Hi

No way. When running the scripts have no information about their provenience. They can only access the document's query string : [tt]document.location.search[/tt] .

When you see such code like you posted, the JavaScript is generated by a server-side script and the parameters are used by that.

Feherke.
 
No way. When running the scripts have no information about their provenience (sic).

While technically true, their provenance can be deduced. The well-known scriptaculous library does this based upon the name of a script file, so I'd use that method in the absence of anything else such as running the JS as a server-side parsed file (e.g. PHP, ASP, etc).

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

[tt][ignore][offtopic][/ignore][/tt]
Hmm... Neither FireFox's spellchecker, the [tt]ispell[/tt] tool and Answers.com's 1-Click Answers objected for "provenience".
[tt][ignore][/offtopic][/ignore][/tt]


Feherke.
 
Wikipedia's take on the two words:
Usually the two terms are synonymous; however, some researchers use provenience to refer only to the exact location in a site where an artifact was excavated, in contrast to provenance which includes the artifact's complete documented history.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top