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.

Problem with window.top.

dmjpro
2,476 2GB
Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="abc" value="  Copy 2 Clipboard" onclick="window.top.value=this.value;" />
  2. <a href="test.html" target="_blank">Open a new window!!!!</a>
  3. <input type="text" name="abc1" value="" onclick="this.value=typeof window.top.value!='undefined'?window.top.value:'';"/>
  4.  
Now i m opening the same page at a different window.
There if i click on the text box then i m getting the undefined value of top.value
Why it's happening?
can't i get the [b]top.value[b] from any children window of that top window?
Where i am wrong?

Debasis Jana.
Jul 9 '08 #1
13 3113
dmjpro
2,476 2GB
I changed my code to ....

I have my two source codes.
those are given below!

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Simple Test</title>
  6. <script type="text/javascript">
  7. window.top.test_value = null;
  8. function test_abc(){
  9.     window.top.test_value = "Debasis Jana....!!!!";
  10.     alert(window.top.test_value);
  11. }
  12.  
  13. function getTopVal(){
  14.     var tmp = window;
  15.     while(tmp.opener){
  16.         tmp = tmp.opener;
  17.     }
  18.     alert(tmp.top.value);
  19. }
  20. </script>
  21. </head>
  22. <body">
  23. <input type="button" name="abc" value="  Copy 2 Clipboard" onclick="window.top.value=this.value;" />
  24. <a href="test1.html" target="_blank">Open a new window!!!!</a>
  25. <input type="text" name="abc1" value="" onclick="getTopVal();"/>
  26. </body>
  27. </html>
  28.  
  29.  
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <script type="text/javascript">
  6. function getTopVal(){
  7.     var tmp = window;
  8.     while(tmp.opener){
  9.         tmp = tmp.opener;
  10.     }
  11.     alert(tmp.top.value);
  12. }
  13. </script>
  14. <title>Test!!!</title>
  15. </head>
  16.  
  17. <body>
  18. <input type="text" name="abc2" value="" onclick="getTopVal();"/>
  19. </body>
  20. </html>
  21.  
  22.  
Now it's working as i expected!
:-)
Jul 9 '08 #2
hsriat
1,654 Expert 1GB
What is this window.top.value?
Never heard about this.
Jul 9 '08 #3
acoder
16,027 Expert Mod 8TB
Not sure what you were trying to do. window.top usually refers to the top frame. If you wanted to set a value, you could have set a global variable.
Jul 10 '08 #4
dmjpro
2,476 2GB
Not sure what you were trying to do. window.top usually refers to the top frame. If you wanted to set a value, you could have set a global variable.
See what i am trying to do i want to save a value some where and i want to make available this value to any children window of that window.
So i thought it's better to save in top window's reference.
Anyway i can also save in that window's reference.
Anyway by this experiment i came to know the actual reality of top. :-)

Debasis Jana
Jul 10 '08 #5
acoder
16,027 Expert Mod 8TB
Yes, window.test_value would have been enough. Then from the child windows, window.opener.test_value should give you the value you need.
Jul 10 '08 #6
dmjpro
2,476 2GB
Yes, window.test_value would have been enough. Then from the child windows, window.opener.test_value should give you the value you need.
Yeah that also be fine. :-)
Thanks Acoder!
Jul 10 '08 #7
acoder
16,027 Expert Mod 8TB
No problem. You're welcome :)
Jul 10 '08 #8
dmjpro
2,476 2GB
No problem. You're welcome :)
Thanks again!!
Sorry Acoder I forgot to mention one thing that in my case there is no way rather than using top.
Actually i want to save the value from a window which can be at any frame of the main window. And the child window may be from another frame of the main window.
So here is only option is top.

Debasis Jana.
Jul 11 '08 #9
acoder
16,027 Expert Mod 8TB
In that case, you could use window.top.test_value or top.opener.top.test_value (for frame in a popup window).
Jul 11 '08 #10
dmjpro
2,476 2GB
In that case, you could use window.top.test_value or top.opener.top.test_value (for frame in a popup window).
Yeah that's what i m using top ..and i already found the solution.
i am using this function to find out that value.

Expand|Select|Wrap|Line Numbers
  1. function getTopVal(){
  2.     var tmp = window;
  3.     while(tmp.opener){
  4.         tmp = tmp.opener;
  5.     }
  6.     alert(tmp.top.value);
  7. }
  8.  
Anyway, Thanks for your help!
Jul 11 '08 #11
acoder
16,027 Expert Mod 8TB
Yeah, I did see that, but I would avoid "value" because it can be confusing.
Jul 11 '08 #12
dmjpro
2,476 2GB
Yeah, I did see that, but I would avoid "value" because it can be confusing.
Ohh...!!!
That's what you were saying.....test_value.
lolz!

Debasis Jana
Jul 11 '08 #13
acoder
16,027 Expert Mod 8TB
Yes, exactly! We finally got there ;)
Jul 11 '08 #14

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
2
by: Bonj | last post by:
Hello Can anyone assist with the following class hierarcy problem? I have a series of window classes, the object model currently being as such: Window / | \ / | \...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
4
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with...
14
by: Christian Kaiser | last post by:
We have a component that has no window. Well, no window in managed code - it uses a DLL which itself uses a window, and this is our problem! When the garbage collector runs and removes our...
37
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window,...
1
by: rsteph | last post by:
I bought a book to help me learn to use DirectX with windows programming. It's first trying to walk me through some basic windows programming and graphics before getting into DirectX. I'm trying to...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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: 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
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
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.