window.location.replace and propagation of onkeydown event in aniframe...

H

hzgt9b

Using VS2005, VB.NET and lots of javascript,

BACKGROUND
I have a web app its (grasp) main page in frames. There are three
frames (1) left frame for navigation links, (2) buttonbar frame for
navigation buttons and (3) a content pane where the links are opened.

The content pane contains an iframe that is dynamically sized by
javascript to fit the viewport of the the content pane it resides in.
All the content from the navgation buttons and links (frames 1,2) are
opened inside the iframe inside the cotent pane. The pages being
opended in the iframe are PPT slides converted to HTML (automatically
by M$ PPT).

QUESTION 1
When the HTML pages (that were converted from PPT) are opened the
following javscript runs:

window.location.replace('myContentPage.htm');

Given that this is being opened inside an iframe which is inside
another frame, which object will have its location changed the iframe
or the content frame?


QUESTION 2
I want to trap the onkeydown event in the content pane. I added the
onkeydown event handler to the body of the page that defines the
iframe but it appears that those events are not propagaed out of the
iframe to my content frame. Does anyone know how to propagte the key
events up and out of the iframe so that I can catch them in my content
pane.


your thoughts appreciated...
 
D

David Mark

Using VS2005, VB.NET and lots of javascript,

BACKGROUND
I have a web app its (grasp) main page in frames. There are three
frames (1) left frame for navigation links, (2) buttonbar frame for
navigation buttons and (3) a content pane where the links are opened.

Frames were never a good idea. They are pretty much extinct these
days.
The content pane contains an iframe that is dynamically sized by
javascript to fit the viewport of the the content pane it resides in.

That you can probably do with CSS. If it wasn't an iframe, it would
certainly be possible (I seem to remember an issue with sizing an
iframe element to 100% by 100% in IE.) Try this:

html { border:none;padding:0;height:100%;overflow:hidden }
iframe { height:100%;width:100%;position:absolute;left:0;top:0 }

Change html to body if using quirks mode.
All the content from the navgation buttons and links (frames 1,2) are
opened inside the iframe inside the cotent pane. The pages being
opended in the iframe are PPT slides converted to HTML (automatically
by M$ PPT).

QUESTION 1
When the HTML pages (that were converted from PPT) are opened the
following javscript runs:

        window.location.replace('myContentPage.htm');

Given that this is being opened inside an iframe which is inside
another frame, which object will have its location changed the iframe
or the content frame?

The iframe.
QUESTION 2
I want to trap the onkeydown event in the content pane. I added the
onkeydown event handler to the body of the page that defines the
iframe but it appears that those events are not propagaed out of the
Right.

iframe to my content frame. Does anyone know how to propagte the key
events up and out of the iframe so that I can catch them in my content
pane.

You cannot do that, but you can call functions in the iframe's parent
window (or any of the other frames) from your event listeners.
your thoughts appreciated...

I would seriously consider losing the frameset.
 
H

hzgt9b

Frames were never a good idea.  They are pretty much extinct these
days.


That you can probably do with CSS.  If it wasn't an iframe, it would
certainly be possible (I seem to remember an issue with sizing an
iframe element to 100% by 100% in IE.)  Try this:

html { border:none;padding:0;height:100%;overflow:hidden }
iframe { height:100%;width:100%;position:absolute;left:0;top:0 }

Change html to body if using quirks mode.





The iframe.




You cannot do that, but you can call functions in the iframe's parent
window (or any of the other frames) from your event listeners.




I would seriously consider losing the frameset.

I agree with you regarding frames but I am stuck with frames at this
point (deadline in a couple of days) so any discussion along those
lines is moot for now.

So, how do I "...call functions in the iframe's parent window" (i.e.
the content frame)? Example?
 
D

David Mark

I agree with you regarding frames but I am stuck with frames at this
point (deadline in a couple of days) so any discussion along those
lines is moot for now.

So, how do I "...call functions in the iframe's parent window" (i.e.
the content frame)? Example?

You've got a project with "lots of JavaScript" and a deadline in a
couple of days. You picked a hell of a time to learn browser
scripting.

Try this:

var global = this;

document.onkeydown = function(e) {
global.parent.myFunction(e || global.event);
};

Of course, your production code should pull the required data (e.g.
the key code) and send that instead of the event object.

Best of luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top