Hi! how can I detect the frames in a web page with Javascript? I mean, I want to detect the frames and set an alert with all frames contain in a Web page.
Thanks again!!!
25 2654
gives you all the frames within the current window object.
OK, thanks, and what is the difference between put "document" and not "window"? is it possible?
Kind regards
The Document object doesn't have a frames collection while the Window object does.
Mmmm this is intersting because I found that document object could have a frame object . I don't know if I get confuse, if I am, I was wondering if you could explain me that.
Another thing, is it correct to put this?: - els=window.frames[].document.body.getElementsByTagName('*');
This is for read something or all the objects contain in the show frame document, I don't know if it could be possible.
Kind regards
Mmmm this is intersting because I found that document object could have a frame object . I don't know if I get confuse, if I am, I was wondering if you could explain me that.
Try it in Firefox - I think you'll get an error.
Another thing, is it correct to put this?: - els=window.frames[].document.body.getElementsByTagName('*');
frames[] is an array, so you want to access one frame at a time, e.g. - els=window.frames[0].document.body.getElementsByTagName('*');
Well, I allways use Firefox and as you said it detect some errors.
If I want to detect something like a handling event in a frame, how can I do it? I think I need to determine how many frames exist in a web page and loop that frames right?, would you like to give an example if it is possible?.
By the way, I tried to adapt to my code that you had seen before, I know I bug you with the same thing but I tried to make grow-up this script with different Web formats, so I modified the line "els=..." but I think I'm wrong: - <html>
-
<head>
-
<title>Prueba Frames</title>
-
<script type="text/javascript">
-
-
window.onload=function() {
-
<!--modify line, but it doesn't work!!! :( -->
-
els=window.frames[0].document.body.getElementsByTagName('*');
-
for(c=0;c<els.length;c++){
-
els[c].onclick=function(){
-
getOnclicks(this);
-
}
-
}
-
}
-
-
function getOnclicks(el) {
-
cadena=new String("?COLAB_CLICK=YES");
-
var url=String(el.getAttribute('href'));
-
if (el.tagName=="A"){
-
alert(el.href=el.href + cadena);
-
}
-
-
}
-
-
</script>
-
-
</head>
-
<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
-
<FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
-
<FRAME src="jo4.html" name="lol" title="Jo41">
-
-
<FRAME src="jo2.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
-
</FRAMESET>
-
</html>
Thank you
To loop through frames, try something like: - for (i = 0; i < window.frames.length; i++) {
-
// now window.frames[i] would be the current frame in the loop
-
}
Ok thanks, I tried yet and it seems that work normaly. When I put an alert to know how many frames I have in the window the alert does not appear. This is my test code: - <html>
-
<head>
-
<title>Prueba Frames</title>
-
<script type="text/javascript">
-
-
window.onload=function() {
-
for(c=0;c<window.frames.length;c++){
-
getjojo(c);
-
}
-
}
-
}
-
-
function getjojo(r) {
-
alert(r);
-
}
-
</script>
-
-
</head>
-
<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
-
<FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
-
<FRAME src="jo4.html" name="lol" title="Jo41">
-
-
<FRAME src="jo2.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
-
</FRAMESET>
-
</html>
I think when I pass the parameter should work. I also tried to eliminate the function but I obteined the same results :(. What can I do?.
Kind regards
You've got some syntax errors in your code. Check your brackets.
You have two frameset tags.
Do you just want the total length or an alert for each frame?
I just want to show the total frames in my page with an alert, not an alert in every frame.
I just want to show the total frames in my page with an alert, not an alert in every frame.
Then forget the for loop and just try: - alert(window.frames.length);
Well at list send me an alert with "undefined" message, I put away th window.onLoad=function and it works; if I put this it doesn't work...
Thanks again
- window.onload=function() {
-
alert(window.frames.length);
-
}
-
should work. Have you still got two frameset tags (with the onload in one of them)?
Ok, I tried this code with and without the 2 frameset tag and nothing happend :(, I don't know why. Even the undefined message doesn't appear anymore!!!
Ok, I tried this code with and without the 2 frameset tag and nothing happend :(, I don't know why. Even the undefined message doesn't appear anymore!!!
I meant removing one frameset tag.
The onload in the frameset is probably overriding the window.onload.
[HTML]<FRAMESET rows="30%,70%" title="">[/HTML]
Nop, I put away these things and nothig, I start to think that this could be not posible. In the other hand I think it should be a way to detect them (not exactly show in an alert) and work with the document that frame has in. What tho you think? could be the right anwser to this problem?
Thanks
This example works:
[HTML]<html>
<script type="text/javascript">
window.onload=function() {
alert(window.frames.length);
}
</script>
<frameset rows="50%,50%">
<frame src="frame_a.htm" />
<frame src="frame_b.htm" />
</frameset>
</html>[/HTML]
Yeah! it works, I see that I had a mistake in the code ("length" and not "lenght") and it works now. Only I have a question, as you said I put off the "onLoad" in the frameset tag and it works, is there any way to do the same thing with the function "onLoad" in the frameset tag?.
Thanks
Only I have a question, as you said I put off the "onLoad" in the frameset tag and it works, is there any way to do the same thing with the function "onLoad" in the frameset tag?
Do you mean call the function in the frameset tag's onload inline?[HTML]<frameset cols="50%,50%" onload="youMeanHere()">[/HTML]
Nop I meant put window.onload=function without put off the onLoad in the frames like this: - window.onload=function{
-
...
-
}
-
-
<FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
-
</html>
Is it possible?
Thanks
Nop I meant put window.onload=function without put off the onLoad in the frames like this:
Add "top.loadFrames()" as an extra statement in window.onload.
Yep!!! it works but maybe I didn´t understand you at all when you said something about the "loadFrame". The fact is that this "loadFrame" is a function made by the original autor XD. By the way, is there any way to call or get the frame name propierty? as you know the frames have names, I think I could control the frames calling them by their own names. Is it possible?
Kind regards
Thanks I already made it!!! thanks a lot!!! XD
You're welcome. Glad you got it working.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Catherine Lynn Smith |
last post by:
Is there a way in ASP to figure out if a page that is being loaded is
being loaded into a frameset? I know I can code this in javascript,
but I would prefer to only inject a chunk of 'onload' code...
|
by: foldface |
last post by:
Hi
Given a web page using frames, is there anyway the left frame can request a
page in the right frame and, most importantly, detect when it has fully
loaded?
Ideally this requires no changes to...
|
by: manuelgk |
last post by:
Hello everybody!!, as you see I have been trying the "urls-click detector" in my example pages and in other pages of the Web. Yesterday, I downloaded the JDK and as you know it has its own tutorial...
|
by: jhardman |
last post by:
I have an old site built with frames, and I plan to leave it in frames for now. The problem is that occasionally I find links (from outside) lead me to just the content frame which means most of the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |