473,799 Members | 2,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass param to JS file?

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

<script language="JavaS cript" src="Tracking.j s"
type="text/javascript"></script>

Neither of these methods work:

<script language="JavaS cript" src="Tracking.j s?someid=303"
type="text/javascript"></script>

or

<script language="JavaS cript" src="Tracking.j s"
type="text/javascript">var someid = 303;</script>

or

<script>var someid = 303;</script>
<script language="JavaS cript" src="Tracking.j s"
type="text/javascript"></script>

Any suggestions?

Thanks,
Brett

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

<script language="JavaS cript" src="Tracking.j s"
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="JavaS cript" src="Tracking.j s?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="JavaS cript" src="Tracking.j s"
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="JavaS cript" src="Tracking.j s"
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/rasterTriangleD OM.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="JavaS cript" src="Tracking.j s"
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
2852
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 reference but set no default value, then the parser has no problems. I've resovled this for now by taking out the "false" default values. But how shall I handle those situations (there are many) where I wish to pass an object by reference but I'm not...
3
2356
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 File. For the life of me I cannot fiqure out how to pass a parameter from this code to the "Proposal" Query in the Access Front End. If I do not add the param variable then everthing works fine except that it pulls all of the matching records...
4
3411
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 42. They say that 42 is printed the second time since the value was wrapped in a class and therefore became passed by reference. (sorry for any typos I am a newbie here ;-)
2
3132
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 control. Ideally i'd like to do something like this: <object type="application/x-shockwave-flash" data="flash/navigation.swf?page=<%pageName%>" width="850" height="148"> <param name="movie" value="flash/navigation.swf?page=<%pageName%>" />...
4
157328
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: session_set_save_handler(array(&$sess_handler, 'open'), array(&$sess_handler, 'close'), array(&$sess_handler, 'read'), array(&$sess_handler, 'write'), array(&$sess_handler, 'destroy'), array(&$sess_handler, 'gc'));
1
2556
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 reference: //Managed c++ QueryResult* qr = NULL; ExecuteQuery(1, "abc", qr); //invoke native c++ method passing qr by reference
0
1407
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
4738
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 format: struct mst_ {
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.