473,379 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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:
myTextAreaOnTheRight = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTheRight = ""; '
doesnt work,

'alert(anything);
myTextAreaOnTheRight = ""; '

does.

(I`m using IE 6 on windows)

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


Jul 23 '05 #1
6 1621
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:
myTextAreaOnTheRight = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTheRight = ""; '
doesnt work,

'alert(anything);
myTextAreaOnTheRight = ""; '

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*****@litotes.demon.co.uk> skrev i melding
news:ch*******************@news.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:
myTextAreaOnTheRight = "";
UNLESS I put an alert(anything) before the statement.

So,

'myTextAreaOnTheRight = ""; '
doesnt work,

'alert(anything);
myTextAreaOnTheRight = ""; '

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.frames[2].document.getElementById("ta1");
alert("DEBUG");
textfield1.value = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.frames[2].document.getElementById("ta1");
textfield1.value = "";
}

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.com...
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.frames[2].document.getElementById("ta1");
alert("DEBUG");
textfield1.value = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.frames[2].document.getElementById("ta1");
textfield1.value = "";
}

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('somepage.html', 'someName');
// alert('DEBUG');
var textfield1 = w.document.getElementBy('ta');
textfield1.value = '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.getElementById('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*****@agricoreunited.com>
comp.lang.javascript 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*****@agricoreunited.com> skrev i melding
news:41***************@agricoreunited.com...
oeyvind toft wrote:
This works:

function init()
{
textfield1 = window.top.frames[2].document.getElementById("ta1");
alert("DEBUG");
textfield1.value = "";
}

This doesnt work:

function init()
{
textfield1 = window.top.frames[2].document.getElementById("ta1");
textfield1.value = "";
}

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('somepage.html', 'someName');
// alert('DEBUG');
var textfield1 = w.document.getElementBy('ta');
textfield1.value = '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.getElementById('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*****@agricoreunited.com>
comp.lang.javascript 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
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...
5
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...
4
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...
11
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...
8
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...
0
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 ...
2
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...
2
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....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.