473,796 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Puzzling frame prob

I have a frameset consisting of 3 frames: top, left and right.

In top frame: body onload calls a js init function to set (or resets) values
in textareas etc...in all frames.

In right frame: A large textarea for dynamicly updated text.

Problem: When clicking the browser 'update' this doesnt work:
myTextAreaOnThe Right = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTh eRight = ""; '
doesnt work,

'alert(anything );
myTextAreaOnThe Right = ""; '

does.

(I`m using IE 6 on windows)

Any ideas ??
Oeyvind
--
http://home.online.no/~oeyvtoft/ToftWeb/


Jul 23 '05 #1
6 1640
oeyvind toft wrote:
I have a frameset consisting of 3 frames: top, left and right.

In top frame: body onload calls a js init function to set (or
resets) values in textareas etc...in all frames.

In right frame: A large textarea for dynamicly updated text.

Problem: When clicking the browser 'update' this doesnt work:
myTextAreaOnThe Right = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTh eRight = ""; '
doesnt work,

'alert(anything );
myTextAreaOnThe Right = ""; '

does.

(I`m using IE 6 on windows)

Any ideas ??


Modifying the text contents of a textarea would usually involve
assigning a string to the - value - property of that textarea. You
appear to be assigning an empty sting to an identifier.

But the question you are actually asking is: "Why does some javascript
code that you cannot see behave in a particular way when interacting
with a series of HTML pages that your cannot see?". You can consider
yourself extremely lucky if you get a useful answer to that question.

Richard.
Jul 23 '05 #2

You are of course correct in pointing out the missing '.value'.
However, it is an error in my email, not in the code I`m talking about.
But the question you are actually asking is: "Why does some javascript
code that you cannot see behave in a particular way when interacting
with a series of HTML pages that your cannot see?". You can consider
yourself extremely lucky if you get a useful answer to that question.
Huh ??

My question was why an assignement works fine WITH an alert placed before
it,'
and doesnt work WITHOUT it.
Oeyvind
--
http://home.online.no/~oeyvtoft/ToftWeb/

"Richard Cornford" <Ri*****@litote s.demon.co.uk> skrev i melding
news:ch******** ***********@new s.demon.co.uk.. . oeyvind toft wrote:
I have a frameset consisting of 3 frames: top, left and right.

In top frame: body onload calls a js init function to set (or
resets) values in textareas etc...in all frames.

In right frame: A large textarea for dynamicly updated text.

Problem: When clicking the browser 'update' this doesnt work:
myTextAreaOnThe Right = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTh eRight = ""; '
doesnt work,

'alert(anything );
myTextAreaOnThe Right = ""; '

does.

(I`m using IE 6 on windows)

Any ideas ??


Modifying the text contents of a textarea would usually involve
assigning a string to the - value - property of that textarea. You
appear to be assigning an empty sting to an identifier.

But the question you are actually asking is: "Why does some javascript
code that you cannot see behave in a particular way when interacting
with a series of HTML pages that your cannot see?". You can consider
yourself extremely lucky if you get a useful answer to that question.

Richard.

Jul 23 '05 #3
Lee
oeyvind toft said:


You are of course correct in pointing out the missing '.value'.
However, it is an error in my email, not in the code I`m talking about.
But the question you are actually asking is: "Why does some javascript
code that you cannot see behave in a particular way when interacting
with a series of HTML pages that your cannot see?". You can consider
yourself extremely lucky if you get a useful answer to that question.


Huh ??


He's hinting that you need to show us the exact code that's
causing the problem. There are many possible reasons why
adding an alert() might work-around a design problem.

Jul 23 '05 #4
This works:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
alert("DEBUG");
textfield1.valu e = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
textfield1.valu e = "";
}

Happy now ??

'There are many possible reasons why
adding an alert() might work-around a design problem.'

Like what ??

I have to admit I`ve never ever before seen a variable assigment`s success
been
dependent on a meaningless alert placed before it.
Oeyvind

--
http://home.online.no/~oeyvtoft/ToftWeb/

"Lee" <RE************ **@cox.net> skrev i melding
news:ch******** *@drn.newsguy.c om...
oeyvind toft said:


You are of course correct in pointing out the missing '.value'.
However, it is an error in my email, not in the code I`m talking about.
But the question you are actually asking is: "Why does some javascript
code that you cannot see behave in a particular way when interacting
with a series of HTML pages that your cannot see?". You can consider
yourself extremely lucky if you get a useful answer to that question.


Huh ??


He's hinting that you need to show us the exact code that's
causing the problem. There are many possible reasons why
adding an alert() might work-around a design problem.

Jul 23 '05 #5
oeyvind toft wrote:
This works:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
alert("DEBUG");
textfield1.valu e = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
textfield1.valu e = "";
}

Happy now ??
Not quite. When does init() run? Are you absolutely positive that the content
of top.frames[2] has completely loaded before you call this function? If init()
runs as the window.onload event of the frame it is in, it is entirely possible
that the content of top.frames[2] is not completely loaded before it runs.

If the content of top.frames[2] is not loaded when you run this function, the
assignment to textfield1 should fail, and an alert() after the assignment
shouldn't resolve the problem, however there may be strange race conditions
within the JavaScript interpretor that allow this behaviour. Either that your
your real example places the alert() before the assignment to textfield1, in
which case it's a simple matter of the alert() providing enough of a delay to
allow top.frames[2] to load.
'There are many possible reasons why
adding an alert() might work-around a design problem.'

Like what ??
Like trying to access the content of another frame/window before it is
completely loaded. Adding alert() provides enough delay for the content of the
other frame/window to load completely.

<script type="text/javascript">
var w = window.open('so mepage.html', 'someName');
// alert('DEBUG');
var textfield1 = w.document.getE lementBy('ta');
textfield1.valu e = 'something';
</script>

The above code is almost certain to fail because somepage.html is unlikely to
be completely loaded by the time you attempt to make the assignment ot
textfield1. Uncomment the alert() however, and now the asynchronous loading of
the new window has time to finish before the script continues.
I have to admit I`ve never ever before seen a variable assigment`s success
been
dependent on a meaningless alert placed before it.
When dealing with cross-frame or multi-window scripting where things are
happening asynchronously, it is very easy to create race conditions where
things will work only with an alert(), or will work intermitantly.

The best way to deal with these situations is have each frame look after it's
own business. In other words, the frame containing the init() function
shouldn't be "reaching into" top.frames[2] to clear the value. Ideally,
top.frames[2] should clear it's own value, but if you have a reason to have it
happen from frames[0], then do something like:

-- in top.frames[2]

<body
onload="
if (top.frames[0].clearTextInput ) {
top.frames[0].clearTextInput (document.getEl ementById('ta') );
}
"


-- in top.frames[0]

<script type="text/javascript">
function clearTextInput( txtInput) {
if (txtInput) {
txtInput.value = '';
}
}
</script>

This code guarantees that top.frames[2] is actually completely loaded before an
attempt is made to clear it's text area.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #6
Hello grant

Thanks a lot for a great reply to my question.
Your thorough explanation made me a lot wiser when
it comes to the mix of frames and javascript...

Best regards,

Oeyvind

--
http://home.online.no/~oeyvtoft/ToftWeb/

"Grant Wagner" <gw*****@agrico reunited.com> skrev i melding
news:41******** *******@agricor eunited.com...
oeyvind toft wrote:
This works:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
alert("DEBUG");
textfield1.valu e = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.fram es[2].document.getEl ementById("ta1" );
textfield1.valu e = "";
}

Happy now ??
Not quite. When does init() run? Are you absolutely positive that the

content of top.frames[2] has completely loaded before you call this function? If init() runs as the window.onload event of the frame it is in, it is entirely possible that the content of top.frames[2] is not completely loaded before it runs.

If the content of top.frames[2] is not loaded when you run this function, the assignment to textfield1 should fail, and an alert() after the assignment
shouldn't resolve the problem, however there may be strange race conditions within the JavaScript interpretor that allow this behaviour. Either that your your real example places the alert() before the assignment to textfield1, in which case it's a simple matter of the alert() providing enough of a delay to allow top.frames[2] to load.
'There are many possible reasons why
adding an alert() might work-around a design problem.'

Like what ??
Like trying to access the content of another frame/window before it is
completely loaded. Adding alert() provides enough delay for the content of

the other frame/window to load completely.

<script type="text/javascript">
var w = window.open('so mepage.html', 'someName');
// alert('DEBUG');
var textfield1 = w.document.getE lementBy('ta');
textfield1.valu e = 'something';
</script>

The above code is almost certain to fail because somepage.html is unlikely to be completely loaded by the time you attempt to make the assignment ot
textfield1. Uncomment the alert() however, and now the asynchronous loading of the new window has time to finish before the script continues.
I have to admit I`ve never ever before seen a variable assigment`s success been
dependent on a meaningless alert placed before it.
When dealing with cross-frame or multi-window scripting where things are
happening asynchronously, it is very easy to create race conditions where
things will work only with an alert(), or will work intermitantly.

The best way to deal with these situations is have each frame look after

it's own business. In other words, the frame containing the init() function
shouldn't be "reaching into" top.frames[2] to clear the value. Ideally,
top.frames[2] should clear it's own value, but if you have a reason to have it happen from frames[0], then do something like:

-- in top.frames[2]

<body
onload="
if (top.frames[0].clearTextInput ) {
top.frames[0].clearTextInput (document.getEl ementById('ta') );
}
"

-- in top.frames[0]

<script type="text/javascript">
function clearTextInput( txtInput) {
if (txtInput) {
txtInput.value = '';
}
}
</script>

This code guarantees that top.frames[2] is actually completely loaded

before an attempt is made to clear it's text area.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3443
by: Maik Wiege | last post by:
Hi! I want to show a blinking text over my derived CMDIChildWnd-class. The blinking is done by one view which is hold by my frame. I set up a timer and write text to the parent frame, which works fine. But I can't get the text away the next time the timer fires. Here is some code: void MyView::OnTimer(UINT nIDEvent) { if (nIDEvent!=1) return; showText = !showText;
5
4456
by: Frame | last post by:
I'm looking for tutorials or articles considering HTML Frames and how to handle them with Javascript. E.g. samples how Frames can exchange information, can a Frame instruct other Frame to update it's content etc. This kind of information is welcome. Cheers!
4
3631
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
11
16962
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got the following frame structure at the top level: FRAMESET CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"> <html><head><title>Server List</title></head> <frameset frameborder="1" border="1" framespacing="1" rows="10%,89%">
8
3817
by: Veerle | last post by:
Suppose having a frameset consisting of two frames, both with dark background colors. One of the frames is a sort of menu and the other one contains the content. When someone clicks a menu item in the first frame, another page is loaded in the second frame. I know it is not a nice solution, but given this situation, is it possible to set the background color of the second frame, so that in between loading the pages with a dark background...
0
1406
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME LASTNAME DATE OF BIRTH And i finished it but there is little prob: it don't output date of birth! I thinkt about the prob and can't figure out why is that happening. To output data i used function: void output(void),i have...
2
1519
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some changes in table and try to update it does not work. It does not give any error. It seems like all fine. but when I retrieve the data via application menas data grid control on form. shows only previous data. no updates. i am using acess...
2
1178
by: saikatkolkata | last post by:
I had been searching ways in net how to connect two frames... my prob is...see i hav a screen with two frames n on the left frame i have a tree view. on selecting a tree node...some relevant info. should come in the right frame.thats it. m doing this in ASP.Net2 with C#. wht i got in net that to set the target as the ID of the other frame..but it didn't work... help~
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9525
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.