473,405 Members | 2,300 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,405 software developers and data experts.

set external .js parameter in the HTML page -possible

2
Hello,
I want to send a parameter (string) to an external js file.

I found something very similar to what I wanted with you but it doesn't answer my question, so here goes:


I call my external js like this

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="diapo.js"></script>
and the diapo.js holds this

Expand|Select|Wrap|Line Numbers
  1.     var special="images/34b"
  2.         var seqslides=new Array()
  3.         seqslides[0]=[special+".jpg"]
  4.         seqslides[1]=[special+".jpg"]
  5.         seqslides[9]=[special+".jpg"]
  6.         seqslides[10]=[special+".jpg"]
  7.         seqslides[18]=[special+".jpg"]
  8.         seqslides[19]=[special+".jpg"]         
  9.  
  10.  
  11.             seqslides[2]=["images/more1.jpg"]         
  12.             seqslides[3]=["images/longbit_gdm.jpg"] 
  13.             seqslides[4]=["images/more2.jpg"]
  14.             seqslides[5]=["images/longbit_programme.jpg"]
  15.             seqslides[6]=["images/more5.jpg"]
  16.             seqslides[7]=["images/longbit_gens.jpg"]
  17.  
......and so on (with the code to be implemented after it ) and this works fine.

The thing is I want to be able to change my variable special depending on the page, and think I should be able to do this by putting the parameter in the HTML but haven't manage to work out how.

This doesn't work

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="diapo.js">special=images/newimage</script>
any help would be much appreciated!
Feb 28 '07 #1
3 1930
acoder
16,027 Expert Mod 8TB
Welcome to The Scripts.

If it's a simple variable, just declare it before you include the file:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. var special = "images/newimage";
  4. //-->
  5. </script>
  6. <script type="text/javascript" src="diapo.js"></script>
The only problem is that you must not overwrite this variable in the js file.
Feb 28 '07 #2
highab
2
thanks, that was what I wanted.
Feb 28 '07 #3
acoder
16,027 Expert Mod 8TB
No problem, you're most welcome.
Feb 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dariusz | last post by:
I currently have a layout that is part written in SHTML - in other words, it gets processed by the web server to execute any calls for PHP or Perl code as well as the html (and external imported...
11
by: Douglas Reith | last post by:
Hi There, Can someone please tell me why the XML spec states that an attribute value with an external entity is forbidden? Or point me to the appropriate document? Or better still, perhaps you...
1
by: Chuck Mendell | last post by:
I am having problem with external javascripts. My OS is XP Pro. I am told to create an external javascript using a .js extension. (I did that) The external .js is very simple, containing: ...
5
by: kinne | last post by:
Is it possible to pass a parameter to an external ".js" file? Kinne
4
by: Mark Anderson | last post by:
Sorry if this is borderline JS vs. HTML. I ask here as the success/failure if the resulting JS is key. I've a small external .JS library that allows a non code-savvy user to occasionally update...
4
by: dennise9 | last post by:
My exeternal JS works fine when the call is placed in the page head or body. But if I call the same javascript from a (clicked) text link on the page, the script throws a JS error when it...
2
by: Jeff Allan | last post by:
Hello, I am trying to load an external HTML page into a DIV tag with .NET 05 and I can't figure it out. Any suggestions? My Scenario: - Gridview populated with list of available files - I...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
2
by: Debbie | last post by:
I have always used VBScript but now need to convert my syntax to JavaScript. In an external file, I have a function that is called when a user clicks a button on a login page. The function checks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.