473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to pass param to JS file?

I need to pass a hard coded value to a JS file:

<script language="JavaScript" src="Tracking.js"
type="text/javascript"></script>

Neither of these methods work:

<script language="JavaScript" src="Tracking.js?someid=303"
type="text/javascript"></script>

or

<script language="JavaScript" src="Tracking.js"
type="text/javascript">var someid = 303;</script>

or

<script>var someid = 303;</script>
<script language="JavaScript" src="Tracking.js"
type="text/javascript"></script>

Any suggestions?

Thanks,
Brett

Jul 23 '05 #1
3 2386
"brett" <ac*****@cygen.com> writes:
I need to pass a hard coded value to a JS file:

<script language="JavaScript" src="Tracking.js"
type="text/javascript"></script>
You can drop the "language" attribute. The "type" attribute is
sufficient and preferred.
Neither of these methods work:
How did you expect them to work?
What happened?

Just saying that it doesn't work does not give us much to go by.
<script language="JavaScript" src="Tracking.js?someid=303"
type="text/javascript"></script>
That doesn't do anything except send the parameter to the server.
The server might use that to put the value directly into the
returned script, but that takes server processing.
<script language="JavaScript" src="Tracking.js"
type="text/javascript">var someid = 303;</script>
No, a script with a "src" attribute should be empty. The content
isn't used.
<script>var someid = 303;</script>
Should be
<script type="text/javascript">var someid = 303;</script>
<script language="JavaScript" src="Tracking.js"
type="text/javascript"></script>
and it should work ... in the sense that the variable is available
for the following script to use. Ofcourse the script needs to be
written to use the variable "someid".
Any suggestions?


I'd go for the last one.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
The last one did work. I needed the type attribute. Thanks.

Jul 23 '05 #3
Lasse Reichstein Nielsen wrote:
"brett" <ac*****@cygen.com> writes:
<script language="JavaScript" src="Tracking.js"
type="text/javascript">var someid = 303;</script>


No, a script with a "src" attribute should be empty. The content
isn't used.


That is not entirely true. The content of such a `script' element is
intended to be an alternative in the case the referenced script resource
could not be accessed (this excludes 4xx and 5xx server responses) or the
`src' attribute is not supported accordingly (it was not defined before
HTML 4).
PointedEars
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
The following class method is being rejected by the PHP parser. If I change the method paramaters and allow the objects to be passed as copies, then the parser has no problem. Or, if I pass by...
3
by: Mark Horton | last post by:
I thought would be a super simple project, but I was wrong. I need Help!!!! I am using the Word.Application.Mailmerge.OpenDataSource to try and send a Dynamic Query to my stated Document.Open...
4
by: z_learning_tester | last post by:
I'm reading the MS press C# book and there seems to be a contradiction. Please tell me which one is correct, 1 or 2. Thanks! Jeff 1. First it gives the code below saying that it prints 0 then...
2
by: rhungund | last post by:
Hi all. I have a user control I'm using as my "include" file for my flash navigation. My asp.net app is written in vb.net. The swf file takes a parameter which I would like to pass into my user...
4
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: ...
1
by: Scott McFadden | last post by:
What is the proper way to pass pointers by reference from managed c++ calls to native c++ calls? In managed C++, I have a pointer to an array of structures, that I pass to a native c++ method by...
0
by: sherryLes | last post by:
Hi All, I m new to XML,and i am breaking head for the last days for the problem. i have a xml file with following format site.xml <sites> <site> <name>,,, <keyword>one</keyword> </site>
6
by: (2b|!2b)==? | last post by:
I am expecting a string of this format: "id1:param1,param2;id2:param1,param2,param3;id" The tokens are seperated by semicolon ";" However each token is really a struct of the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.