By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Urgent!!Global window reference!!

P: n/a
Hi,
In a page, i have many links.
I have some functions in a global file which is included in all
linked pages.
I want to have a reference to a window which is to be opened on
clicking one link and it should be known only to one more link on that
page and not to other links.
I cant have that window reference in that global file, since iam
declaring it initially as Null and modifying its value in that one
particular link. Since all links include this global file they change
the refernce to Null and its value is lost.
What can i do for this?

Plz let me know the earliest..

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 30 Aug 2004 01:36:22 -0700, learner wrote:
Urgent!!Global window reference!!
a) Please give your ..
<http://www.physci.org/kbd.jsp?key=1+shift>
...key a rest
Plz let me know the earliest..


b) Please do not come in here screaming
'Urgent' and asking to be told 'the earliest'..
Your question will be asnswered as soon (and if)
someone feels like it.

c) Please note this is not your personal 24Hr
Help desk, it is acctually a discussion forum,
as expounded in the FAQ..

d) You, ..have *checked* the FAQ, haven't you?
<http://www.jibbering.com/faq>

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2

P: n/a
In article <cg********@odah37.prod.google.com>,
"learner" <v_********@yahoo.com> wrote:
Hi,
In a page, i have many links.
I have some functions in a global file which is included in all
linked pages.
I want to have a reference to a window which is to be opened on
clicking one link and it should be known only to one more link on that
page and not to other links.
Are you using the HTML anchor tag <a> ?

In that case, Evertjan, The Netherlands, answered your question in the
prior post.
I cant have that window reference in that global file, since iam
declaring it initially as Null and modifying its value in that one
particular link. Since all links include this global file they change
the refernce to Null and its value is lost.
The web browser has the responsibility for security and that is a good
thing. The web browser controls the access to variables in a more
absolute manor than you see in c/c++.

How are you getting the window reference? The word link implies you are
using the anchor tag. The words window reference implies that you are
using the window.open function.

Lets say you had files a.html, b.html, and c.html all in the same
directory. Lets say you did this in file a.html:
var myData; // written outside of any function

window.open('b.html',...)
window.open('c.html',...)

Javascript functions in both b.html and c.html would be able to access
variable myData by coding:
opener.myData

You will note that functions in b.html and c.html do not have to declare
opener.myData.

Browser security will require files a.html, b.html, and c.html to all be
in the same directory unless you relax the default security settings.
What can i do for this?


I am not certain what your goal is. Are you trying to employ good
programming practices? Are you trying to encapsulate the data?

A web application can be very big. The nature of the web forces a
decentralized coding style. You will not see the monolithic programs you
find with c/c++ programs. In c/c++, you have to worry more about data
encapsulation. On the web, I think you will find the pieces are smaller.
The web forces you to write decentralized programs. You may feel more
comfortable using global variables in Javascript because there scope is
smaller in the overall picture of your application.

You can use closure to encapsulate your variables if you wish.
See:http://jibbering.com/faq/faq_notes/closures.
I think you need to redesign your application.

Robert
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.