473,624 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing Text to web page in different frame

Hello all:

I have a page with two frames named "menu" and "display".
An event handler in "menu" changes the src attribute for
"display", resulting in a different page being loaded for
each choice in a option list.
I accomplish this as follows:
// .... code
var frameTag = top.document.ge tElementById("d isplay");
var optionValue =
parseInt(listOb ject.options[listObject.sele ctedIndex].value);
// .... code for array of form names
frameTag["src"] = "short-forms/" + adForms[optionValue];
// and the target page is loaded in "display"

The goal is to write text into a font element in whichever page
is in the "display" frame. The font tag is configured as such:
<font id="prop_county _display" color="darkred" >
&nbsp;
</font>
Replacing &nbsp; with the text.

I seem to referencing the font element with the following code:
var countyText =
top["display"].document.getEl ementById('prop _county_display ');
//the following "output stub:
alert('countyTe xt = ' + countyText + ' county: ' + chosenCounty);
//Tells me that I referenced an HTMLFontElement and the text is a
//valid string

The code for writing the text into the FontElement is as follows:
var res =
countyText.repl aceChild(top["display"].document.creat eTextNode(chose nCounty),county Text.firstChild );
// and I test the return value as
alert('result: ' + res);
// which informs me: result: [object Text]

Sadly, no change is made to the target document.

Questions:
1)What am I doing wrong?
2)I have found frames to be a bit tricky, could it be that
this method is not the best?
cgi might work better, I'm certainly much more fluent with
cgi that javascript.

As always
Thanks
Tim
Jul 23 '05 #1
13 3534

Oh boy, haven't you heard that <span> or <div> and that Font is quite
deprecated, or of the .innerHTML property for an element object?
Danny
On Thu, 30 Jun 2005 12:57:39 -0700, Tim Johnson <ti*@johnsons-web.com>
wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2
Danny wrote:

Oh boy, haven't you heard that <span> or <div> and that Font is
quite deprecated, or of the .innerHTML property for an element object?

Hi Danny:
Can you explain further please?
Thanks
Tim
Jul 23 '05 #3
Danny wrote:

Oh boy, haven't you heard that <span> or <div> and that Font is
quite deprecated, or of the .innerHTML property for an element object?

Danny: I did a quick google on .innerHTML The following link:
http://wsabstract.com/javatutors/dynamiccontent4.shtml

I understand from that URL that the .innerHTML property is deprecated by
both W3C and IE.

Regarding your reference to using <div> as a "placeholde r" for dynamic
text (at least that's what I think you mean): This works for
the "original" page that is *originally* sourced by the the "display" frame.

But the kicker is that when I reload a new page into that frame, dynamic
rewrites are failing, and the example I gave is only one. Tested on
firefox and netscape in linux RH 9.0 ....

Tim
Jul 23 '05 #4
Tim Johnson wrote:
Danny wrote:

Oh boy, haven't you heard that <span> or <div> and that Font is
quite deprecated, or of the .innerHTML property for an element object?

Danny: I did a quick google on .innerHTML The following link:
http://wsabstract.com/javatutors/dynamiccontent4.shtml

I understand from that URL that the .innerHTML property is deprecated by
both W3C and IE.


I don't understand how anybody can say the W3C deprecated *anything* in
javascript since the W3C has nothing to do with scripting languages.
That is the area that ECMA covers. But even then, I find it hard to
believe that the ECMA would "deprecate" a feature that was never an ECMA
"feature" to start with.

Or, for that matter, that MS would deprecate *anything* it came up with.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #5
Randy Webb wrote:
Tim Johnson wrote:
Danny wrote:

Oh boy, haven't you heard that <span> or <div> and that Font is
quite deprecated, or of the .innerHTML property for an element object?

Danny: I did a quick google on .innerHTML The following link:
http://wsabstract.com/javatutors/dynamiccontent4.shtml

I understand from that URL that the .innerHTML property is deprecated
by both W3C and IE.

I don't understand how anybody can say the W3C deprecated *anything* in
javascript since the W3C has nothing to do with scripting languages.
That is the area that ECMA covers. But even then, I find it hard to
believe that the ECMA would "deprecate" a feature that was never an ECMA
"feature" to start with.

Or, for that matter, that MS would deprecate *anything* it came up with.


I'm only quoting what is stated in that page. Personally, all I give
a damn about is what works. Let us refocus on the problem:

Regardless of whether or not I use the .innerHTML method, regardless of
whether I use the associative approach or 'hard coded' attribute names,
here is the problem:

Using any of these methods, I *CAN* write to a page in a frame that is
loaded statically (the target of the hand - coded "src" attribute).

I *CAN'T* write to any page that is dynamically loaded by changing the
'src' attribute at the top level.

Please see my original posting.
-------------------------------

Thanks
Tim
Jul 23 '05 #6
Randy Webb wrote:
Tim Johnson wrote:
Danny wrote:

Oh boy, haven't you heard that <span> or <div> and that Font is
quite deprecated, or of the .innerHTML property for an element object?

Danny: I did a quick google on .innerHTML The following link:
http://wsabstract.com/javatutors/dynamiccontent4.shtml

I understand from that URL that the .innerHTML property is deprecated
by both W3C and IE.

I don't understand how anybody can say the W3C deprecated *anything* in
javascript since the W3C has nothing to do with scripting languages.
That is the area that ECMA covers. But even then, I find it hard to
believe that the ECMA would "deprecate" a feature that was never an ECMA
"feature" to start with.


You are failing to distinguish between ECMAScript/JavaScript, on the one
hand, and the DOM on the other. .innerHTML is part of the DOM, which is
very much W3C's business. Both .innerHTML and .write are very strongly
deprecated; in particular, they are not supported with XHTML at all.

(I have no idea about IE, especially since IE doesn't support XHTML in
the first place.)

--
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
-- Charles Williams. "Judgement at Chelmsford"
Jul 23 '05 #7


John W. Kennedy wrote:
You are failing to distinguish between ECMAScript/JavaScript, on the one
hand, and the DOM on the other. .innerHTML is part of the DOM, which is
very much W3C's business. Both .innerHTML and .write are very strongly
deprecated; in particular, they are not supported with XHTML at all.


Where does the W3C deprecate the write method? If browser producers
choose to not implement the write method for XHTML it does not mean the
W3C deprecates the method.

As for innerHTML it has never been part of the W3C DOM but your claim
that it is not supported in XHTML at all is not true, scripting support
in real XHTML pages (application/xhtml+xml) has been flaky and is still
not up to par with scripting of HTML pages (text/html) but Opera 8 for
instance already supports innerHTML in application/xhtml+xml documents
and Mozilla 1.8 nightly builds do support that too so support is there
or coming.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #8
Tim Johnson wrote:
Randy Webb wrote:
I'm only quoting what is stated in that page. Personally, all I give a
damn about is what works. Let us refocus on the problem:

Regardless of whether or not I use the .innerHTML method, regardless of
whether I use the associative approach or 'hard coded' attribute names,
here is the problem:

Using any of these methods, I *CAN* write to a page in a frame that is
loaded statically (the target of the hand - coded "src" attribute).

I *CAN'T* write to any page that is dynamically loaded by changing the
'src' attribute at the top level.

Please see my original posting.
-------------------------------


No solution appears readily available, either from my tests or
from this newsgroup. It seems not a good idea to first dynamically
load a page into a frame and then attempt to write to it from another.

the workaround is to use a cgi process dynamically generated for
the 'frame' tag "src" attribute. I get the results I want that way.

Javascript is a bit like tequila methinks. Used in small amounts,
adds something to the experience, but used to excess, can create
a fr*%in headache. I 'spose the argument would be as to what
constitutes 'excess'.

Turned into a good thread anyway. Thanks folks.
tim
Jul 23 '05 #9
VK
> Javascript is a bit like tequila methinks.

I would say fugurally that you're drinking "Bloody Mary" of your own
mix. ;-)
var res = countyText.repl aceChild(top["d*isplay"].document.creat eTextNo*de(chos enCounty),count yText.fi*rstChi ld);

! ? ! ? ! ?
- It hurts, man! How can you drink it?!

Let's switch at least on tequila methinks:

<!-- in your left frame -->
var frameTag =
top.frames[1].document.getEl ementById("prop _county_display ");
frameTag.innerH TML = "It works!";

<!-- in your right frame -->
<span id="prop_county _display" style="color: darkred">&nbsp</span>
<!-- actually it would be nice to use 'class' for styling; on the next
glass maybe -->

(1) Try never use string names within frames[]. It's senseless (Give me
the property "Display" from frames[] array! Eh?). Most browsers learned
to translate it semi-properly, but not all of them and not always
(Firefox in the particular doesn't like it).
(2) Don't bother with nodes. If you decided to use conventional HTML,
moreover with frames, nodes are ... strange here. Easier you do -
better it will work.

Jul 23 '05 #10

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

Similar topics

2
1781
by: Paul | last post by:
I have a simple frame-based application where title information appears in a top frame and a lower frame contains the content for the application. One of the needs for this app is for a status line in the upper frame to be updated when certain actions are taken in the lower frame. In the top frame, I have a line of text wrapped with SPAN tags and assigned a unique ID attribute. In the lower frame, I run a JS function that looks up the...
3
4255
by: DS | last post by:
I would like to construct a frame in the middle of a page, similar to a text box with scrollers, but I want the part in the box to be AN html page .... What I want to do is take a LARGE amount of news headlines and instead of displaying this long list on a page, or providing a link to an archive page, I want to have a text box (middle of the page mini frame with scrollers) in which I would call a file with the headlines (including...
1
1905
by: MTC | last post by:
Hi all and thanks in advance I have an HTML page with 3 frames. Lets call them top middle and bottom. On the top frame there is a button to run some java script! When it is run I want to put some text into the middle frame, but in to a text box on a form call "testform" textbox name is "TestText" I know I need to address the frame name but what am I missing? Parent.frames("middle").TextText.value = "here is the data"
385
17107
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every one are
14
3985
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
14
1607
by: BrendanMcPherson | last post by:
Hello, Im try to do some tricks to help make a "Search Many Sites from One Location". http://www.act.org.au/b_nexus.htm What I have decided to do is this: 1. You can choose which site you wish to visit from the first page, after pressing go it takes you to a frame page.
42
3857
by: smerf | last post by:
Using javascript, is there a way to trap an external page inside a frame? I've seen scripts to break out of frames, but nothing to keep a page trapped in a frame.
9
2672
by: mel | last post by:
Hi all, I need a persistent TCP connection with my web server over page reloads. This means that, even if the user goes to a different page (in my domain), I want to keep a TCP connection live. I know I can do something similar with globalStorage in FF, window.name & userData on IE, but those storages only hold strings.
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5561
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
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
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
1482
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.