473,563 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

External .js value accessing Local JavaScript variable

Frinavale
9,735 Recognized Expert Moderator Expert
Hi!

I am dynamically generating external .js JavaScript resources to be used with a Tab control I created (using VB.NET).

Originally, the JavaScript was written directly into the <head> of the pages that used Tab controls. Because it was generated in this way I was able to specify which tab was to be displayed as the "current" tab upon rendering the page in the browser.

Since the JavaScript is now a fixed resource that resides on the server, I need to specify which tab is the current tab in a different manner.

I've attempted using a hidden field, but because the hidden field doesn't exist when the JavaScript is executed (recall the JavaScript is executed in the <head> section which is executed before the hidden field...in the <body>.... is created).

Since I could not a hidden field, I attempted adding the variable to the page (in the <head> section above my include for the external JavaScript). This obviously doesn't work....

Does anyone have a recommendation as to where and how to declare this "current tab" variable?

Thanks

-Frinny
Apr 1 '08 #1
2 2213
pronerd
392 Recognized Expert Contributor
I am not entirely sure I follow can you post the HTML/JavaScript output you are getting? It is generally excepted that it is best to have JavaScript in the head tag, but it is not an absolute requirement.

If the JavaScript are generating is in the form of a function you can just put a script call at the end of the page to call it. That way it will not be executed until all of the page elements are loaded.

[HTML]
<html>
<head>
<script>
function someFunction() {
.......
}
</script>
</head>
<body>
Blah Blah Blah
</body>
<script>someFun ction();</script>
</html>
[/HTML]
Apr 1 '08 #2
Frinavale
9,735 Recognized Expert Moderator Expert
I am not entirely sure I follow can you post the HTML/JavaScript output you are getting? It is generally excepted that it is best to have JavaScript in the head tag, but it is not an absolute requirement.

If the JavaScript are generating is in the form of a function you can just put a script call at the end of the page to call it. That way it will not be executed until all of the page elements are loaded.

[HTML]
<html>
<head>
<script>
function someFunction() {
.......
}
</script>
</head>
<body>
Blah Blah Blah
</body>
<script>someFun ction();</script>
</html>
[/HTML]
Thanks for your help Pronerd.

I ended up changing the JavaScript function that is responsible for initializing the Tab control when the page has finished loading in the browser. This function now accepts a variable as a parameter (originally this wasn't working because of some .NET issues that I have now resolved).

It's working fine now :)

Thanks again!

-Frinny
Apr 1 '08 #3

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

Similar topics

3
12376
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I have tried many combinations to do this, but has yet to try the right one. How is it done? 2) What kinds of file operations can be done in...
7
1899
by: ???????J | last post by:
Javascript may inquire the push down menu value, can I inquire the description? The following example, the variable($answer) can be get the menu1's value. For example, if I select first data, the menu1's value would be 1. Therefore ($answer) would be 1. But If want using javascript get the description(ABC),which javascript command can do...
0
1852
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET 2003, although I'm not sure what is actually causing the problem. I can't summarize the issue, so please read on to find out more. I've created a...
1
3225
by: mr_burns | last post by:
Hi, i was wondering if it is possible to load text into a string from an external text file. the reason is that i have a very large string and it is making my script very messy. also, is it possible to have some dynamic parts of the text from the text file? for example, if i load in a string and there is a part of it that inserts a value...
9
6885
by: Charley Kyd | last post by:
I'm a newbie who needs advice about how to use external files of JavaScript code. I spent an hour this afternoon browsing through JavaScript books at the local book store. In about 15 different titles, I found a total of about five pages that covered js files. For all practical purposes, these pages said, "You can use js files. But we won't...
18
2181
by: Joe | last post by:
Hi, I am trying to alter the refresh rate of an online webpage in a webbrowser control using MFC. However the Timer ID is stored in a local variable and I don't know how to access it. Is there a technique in Javascript that I might be able to use/adapt? I have a timer set within a prototype thus: ;HControl.prototype.setFLTimeout =...
3
1753
by: hendedav | last post by:
Hi gang. As with any other post, I am working on a project and have gotten stuck. I am trying to obtain a variable value in the parent webpage from an <iframe>. For instance: Parent Page code ---------------- <html> .... heading tags <body>
4
2728
by: Peter Ammon | last post by:
I would like to share a variable between two functions defined in two separate source files; no other functions will need the global variable so I'd prefer to not give it file scope. Thus, I want a variable with local scope, external linkage, and static storage. I believe I can do this for the file that does not define the variable by...
5
3612
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE")...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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...
0
7885
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. ...
1
7638
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...
0
7948
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...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
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...

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.