Solved

THE MOST DIFFICULT JavaScript QUESTION EVER!

Posted on 1998-02-02
14
168 Views
Last Modified: 2012-06-21
If I want to get the location of a document, I would simply use "self.document.location". But how about getting the frame name of a self document?

This is the frameset I am using for my page:

<FRAMESET cols="145,*,145" border="0" framespacing="0">
      
      <FRAMESET rows="45,*,45" border="0" framespacing="0">
            <FRAME src="name.html" name="leftname" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
            <FRAME src="left.html" name="left" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
            <FRAME src="scroller.html" name="leftscroller" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
             
      </FRAMESET>
      <FRAME src="main.html" name="main" scrolling="auto" noresize frameborder="0" marginheight="0" marginwidth="0">
      
      <FRAMESET rows="45,*,45" border="0" framespacing="0">
            <FRAME src="name.html" name="rightname" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
            <FRAME src="right.html" name="right" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
            <FRAME src="scroller.html" name="rightscroller" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" noresize>
             
      </FRAMESET>
      
</FRAMESET>

So, I am using the "name.html" as the frames "leftname" and "rightname". I would like to make a simple alert from the "name.html" making it show its own frame name.

To understand this confusion better, I will tell you exacly what I want:
1- The leftname frame (name.html) will load first and I want it to alert its own name (but just its own name!): "leftname".
2- After a little while, the rightname frame will be loading (it is the "name.html" too!) and I want it to alert its own name (but just its own name too!): "rightname".

And I want to do that using only one code!! I guess it will be something looking like "self.document.frame.name.value" or "self.parent.document.frame.name"..

Oh... well... this is confuse!
0
Comment
Question by:superquestions
  • 7
  • 6
14 Comments
 
LVL 10

Expert Comment

by:kollegov
ID: 1277966
Easy.....
to alert name from frame itself you need only:

alert(window.name)


0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1277967
good job! :-)
0
 
LVL 1

Author Comment

by:superquestions
ID: 1277968
I tried, but the alert message was "undefined" for the frame named "leftname" and the other alert was "undefined" too for the frame named "rightname"! What I want is to alert "leftname" for the frame named "leftname" and to alert "rightname" for the frame named "rightname"! --> the problem is... I am using the same html file for both frames!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:superquestions
ID: 1277969
This is the "name.html":

<HTML>
<HEAD>
      <SCRIPT>window.defaultStatus='WareZone - The Ultimate Zone of Warez';</SCRIPT>
</HEAD>
<BODY background=namebg.jpg topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0>
      
      <TABLE border=0 cellpadding=0 cellspacing=0 height=100% width=100%>
            <TR valign="middle" align="center">
                  <TD>
<script>if(this.damn.document.frame.name == leftname)
{document.write('<img src=warez.jpg>')}
else if (this.document.which.is.making.me.angry.frame.name == rightname) {document.write('<img src=other.jpg')}</script>
                  </TD>
            </TR>
      </TABLE>
</BODY>
 
</HTML>
</BODY>
 
</HTML>

-------------------> READ THE SCRIPT! That is what I want to do... and... by the way... do you have a homepage?
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1277970
I checked this solution with frameset
which loaded the same html in both frames
and this work in NN3 and NN4, MIE4 for win 95
You so not need to put anytthing else, just copy and paste
this script into your HTML without any changes.
In default context of window should be current frame object

<script>
 alert(window.name)
</script>
0
 
LVL 1

Author Comment

by:superquestions
ID: 1277971
Give me your UIN and we will be able to talk in real time. What do you think? It will be easier for us... mine is 5816043... but how about you?
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1277972
you should compare:
window.name+""=="leftname"
I guess you have 'undefined' on leftname.
without " browser consider it a variable name
which is undefined.

0
 
LVL 1

Author Comment

by:superquestions
ID: 1277973
And don't repeat the word easy again! My name is superquestions... and it could make me really sad...
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1277974
Sorry, Superquestions, I do not have ICQ :( Still it once crashes my filesystem, I do not trust this program.
And it useless this time of day, when connection to thier site from heart of Russia is so slow.
0
 
LVL 1

Author Comment

by:superquestions
ID: 1277975
WAHAHAHAHAHHAHAHHAAHAHAHAHAHAHAH!!! IT WORKED!!! THANK YOU VERY MUCH!!! Give me your UIN... or your homepage address and I will give you an "A" (more one, eh?)!!!
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1277976
What browser you use? Probably this is browser specific problem?
0
 
LVL 10

Accepted Solution

by:
kollegov earned 60 total points
ID: 1277977
Just click on my Name at the left of this message, you will find my homepage address. And there you will find my e-mail if you need it next time :)
0
 
LVL 1

Author Comment

by:superquestions
ID: 1277978
Hmm... you helped me... we are talking in real time right now... hehe..
0
 
LVL 1

Author Comment

by:superquestions
ID: 1277979
I will send you an e-mail soon! I NEED YOUR UIN (I will help you having one...)! And.. by the way.. I am not in the USA, I am in Brazil and there is more than one Mirabilis ICQ server in this world.. there is an option in... ICQ --> Preferences --> Servers to change the servers, then your connection from the middle of Russia would be faster! And the main Mirabilis ICQ server is in Israel, not in the USA!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use javascript to open specific place on an accordian in other page 8 39
Wordpress and Wufoo 1 36
JavaScript code not working 3 31
Jquery if else not working ... WHY? 5 23
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question