Solved

THE MOST DIFFICULT JavaScript QUESTION EVER!

Posted on 1998-02-02
14
164 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now