在不同的框架中将文本写入网页 [英] Writing Text to web page in different frame

查看:66
本文介绍了在不同的框架中将文本写入网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:


我有一个名为menu的两个页面的页面和显示。

菜单中的事件处理程序。更改

" display"的src属性,导致在选项列表中为每个选项加载一个不同的页面



I完成此操作如下:

// ....代码

var frameTag = top.document.getElementById(" display");

var optionValue =

parseInt(listObject.options [listObject.selectedIndex] .value);

// ....表单数组的代码

frameTag [" src"] =" short-forms /" + adForms [optionValue];

//并且目标页面加载在display中


目标是将文本写入字体元素无论哪一页

都在显示中帧。字体标记的配置如下:

< font id =" prop_county_display" color =" darkred">

& nbsp;

< / font>

更换& nbsp;文本。


我似乎用下面的代码引用了font元素:

var countyText =

top [" ; display"]。document.getElementById(''prop_county_display'');

//以下输出存根:

alert(''countyText =''+ countyText +''county:''+ chosenCounty);

//告诉我,我引用了HTMLFontElement,文本是

//有效字符串


将文本写入FontElement的代码如下:

var res =

countyText.replaceChild(top [" display" ] .document.createTextNode(chosenCounty),countyText.firstChild);

//我测试返回值为

alert(''结果:''+ res) ;

//告诉我:结果:[对象文本]


可悲的是,目标文件没有变化。


问题:

1)我做错了什么?

2)我找到了fra mes有点棘手,可能是这个吗?这个方法不是最好的吗?

cgi可能效果更好,我肯定会更流利/>
cgi那个javascript。


一如既往

谢谢

Tim

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.getElementById("display");
var optionValue =
parseInt(listObject.options[listObject.selectedIndex].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.getElementById(''prop_county_display'');
//the following "output stub:
alert(''countyText = '' + 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.replaceChild(top["display"].document.createTextNode(chosenCounty),countyText. 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

推荐答案



哦,小伙子,你没听说过< span>或者< div>那个Font是不是已经弃用了
,还是元素对象的.innerHTML属性?

Danny

2005年6月30日星期四12 :57:39 -0700,Tim Johnson< ti*@johnsons-web.com>

写道:


-

使用Opera革命性的电子邮件客户端: http://www.opera。 com / mail /


Danny写道:

哦,小伙子,你没听说过吗?跨度>或者< div>那个Font已经过时了,或者是元素对象的.innerHTML属性?

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:

可以请进一步解释一下?

谢谢

Tim


Hi Danny:
Can you explain further please?
Thanks
Tim


Danny写道:
<哦,小伙子,你没听说过吗?< span>或者< div>那个Font已经过时了,或者是元素对象的.innerHTML属性?

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:我在.innerHTML上做了一个快速的google以下链接:
http://wsabstract.com/javatutors/dynamiccontent4.shtml


我从该URL了解到,W3C和IE都不推荐使用.innerHTML属性。


关于您对使用< div>的参考作为占位符 for dynamic

text(至少那是我认为你的意思):这适用于

的原始文本最初由*显示来源*的页面框架。


但是,当我将新页面重新加载到该框架中时,动态

重写失败,我给出的示例只有一个。在Linux RH 9.0上测试了

firefox和netscape ....


Tim


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 "placeholder" 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


这篇关于在不同的框架中将文本写入网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆