请问一个问题 [英] A question please

查看:73
本文介绍了请问一个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这个东西很陌生 - 所以这可能是一个令人难以置信的愚蠢的问题。请多多包涵。我不知道这是一个HTML或javascript

问题。 (或者,如果完全不同的区域,请引导我到右边

组。)


我可以查看窗口的成员。具有以下javascript的对象。

它返回所有方法,属性,事件等。


< script type =" text / javascript"> ;

for(我在窗口中)

{

window.document.write(i +"< br />" );

}

< / script>

我可以对文件做同样的事情。对象通过改变表达式

来阅读...


< script type =" text / javascript">

for(我在window.document中)

{

window.document.write(i +"< br />");

}

< / script>

然后我可以查看单个属性,(例如protocol),用

以下。它返回超文本传输​​协议。


< script type =" text / javascript">

window.document.write(window。 document.protocol);

< / script>

到目前为止,这么好......


但是 - 我找不到办法解决html问题。或头部或头部对象。我知道他们是HTML元素,(< html>,< head>),但它们也作为对象存在

,因为我在参考网站上看到他们有方法,属性,事件,

等等所以他们必须是

层次结构中更高的其他对象的子对象。对?必须有一些方法来解决它们。对吗?


例如 - 在MSDN网站上,文档说innerText属性

的html object,设置或检索对象的开始和结束

标记之间的文本。好的 - 使用javascript,我该如何设置或者检索

该财产?


" window.html.innerText"不行。也没有

" window.document.hml.innerText"。是否有一个高于窗口的对象

对象html对象是一个孩子?


任何帮助非常感谢。我一直在盯着这个* ^#(%^监视器,现在大约8个小时,而且我的眼球很疼。

解决方案

Peter写道:


但是 - 我找不到解决html或head对象的方法。我知道他们是HTML元素,(< html>,< head>),但它们也作为对象存在

,因为我在参考网站上看到他们有方法,属性,事件,

等等所以他们必须是

等级中更高的其他对象的子对象。对吗?还有解决这些问题。对吗?



这对我来说在Opera 9中有用


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN">

< html lang =" en">

< head>

< meta http-equiv =" Content-Type" content =" text / html; charset = utf-8&qu ot;>

< title>无标题< / title>

< / head>

< body>

< script type =" text / javascript">

var html = document.getElementsByTagName(''html'')[0];

for(var p in html){

document.write(p +''< br>'');

}

< / script>

< / body>

< / html>


例如 - on在MSDN网站上,文档说innerText是指属性

的html object,设置或检索对象的开始和结束

标记之间的文本。好的 - 使用javascript,我该如何设置或者检索

该财产?



这在Opera 9中适用于查看innerHTML。我不知道什么时候

设置html元素的innerHTML是个好主意。


<!DOCTYPE HTML PUBLIC" - / / W3C // DTD HTML 4.01 // EN">

< html lang =" en">

< head>

< meta http-equiv =" Content-Type"含量=" text / html的; charset = utf-8">

< title>无标题< / title>

< script type =" text / javascript">

window.onload = function(){

alert(document.getElementsByTagName(''html'')[0] .innerHTML);

};

< / script>

< / head>

< body>

< / body>

< / html>

- Peter


Peter写道:
< blockquote class =post_quotes>
我是这个东西的新手 - 所以这可能是一个令人难以置信的愚蠢,新的问题。请多多包涵。我不知道这是一个HTML或javascript

问题。 (或者,如果完全不同的区域,请引导我到右边

组。)


我可以查看窗口的成员。具有以下javascript的对象。

它返回所有方法,属性,事件等。


< script type =" text / javascript"> ;

for(我在窗口中)

{

window.document.write(i +"< br />" );

}

< / script>


我可以对文件做同样的事情。对象通过改变表达式

来阅读...


< script type =" text / javascript">

for(我在window.document中)

{

window.document.write(i +"< br />");

}

< / script>


然后我可以查看单个属性(例如protocol),用

如下。它返回超文本传输​​协议。


< script type =" text / javascript">

window.document.write(window。 document.protocol);

< / script>


到目前为止,这么好....


但是 - 我找不到解决html问题的方法。或头部或头部对象。我知道他们是HTML元素,(< html>,< head>),但它们也作为对象存在

,因为我在参考网站上看到他们有方法,属性,事件,

等等所以他们必须是

层次结构中更高的其他对象的子对象。对?必须有一些方法来解决它们。对吗?


例如 - 在MSDN网站上,文档说innerText属性

的html object,设置或检索对象的开始和结束

标记之间的文本。好的 - 使用javascript,我该如何设置或者检索

该财产?


" window.html.innerText"不行。也没有

" window.document.hml.innerText"。是否有一个高于窗口的对象

对象html对象是一个孩子?


任何帮助非常感谢。我一直在盯着这个* ^#(%^监视器,现在大约8个小时,我的眼球很疼。



1下载Firefox的副本。


2使用自定义安装选项进行安装,以确保DOM Inspector已确认

已检查


3或者更好的是,安装Web Developers Bar扩展程序
https://addons.mozilla.org/firefox/60/

4打开网页并使用DOM Inspector遍历文档

树和查看所有属性。


一个必不可少的学习|调试工具

-

保重,


Jonathan

-------------------

LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com




Jonathan N. Little写道:


Peter写道:


但是 - 我找不到办法解决html问题。或头部或头部对象。我知道他们是HTML元素,(< html>,< head>),但它们也作为对象存在

,因为我在参考网站上看到他们有方法,属性,事件,

等等所以他们必须是

层次结构中更高的其他对象的子对象。对?必须有一些方法来解决它们。对?



1下载Firefox副本。


2使用自定义安装进行安装标记确保DOM Inspector的选项

已检查


3或者更好的是,安装Web Developers Bar扩展名
https://addons.mozilla.org/firefox/60/


4打开网页并使用DOM Inspector遍历文档

树并查看所有属性。



或者甚至比DOM检查员更好
http://getfirebug.com 插件。


彼得


I''m new at this stuff -- so this is probably an incredibly dopey, newby
question. Please bear with me. I don''t know if it''s a HTML or javascript
question. (Or, if a different area altogether, please steer me to the right
group.)

I can view the members of the "window" object with the following javascript.
It returns all the methods, properties, events, etc.

<script type="text/javascript">
for(i in window)
{
window.document.write(i + "<br />");
}
</script>
I can do the same thing for the "document" object by changing the expression
to read...

<script type="text/javascript">
for(i in window.document)
{
window.document.write(i + "<br />");
}
</script>
And then I can check out an individual property, (example "protocol"), with
the following. It returns "HyperText Transfer Protocol".

<script type="text/javascript">
window.document.write(window.document.protocol);
</script>
So far, so good....

But -- I can''t find a way to address the "html" or the "head" objects. I
know they''re HTML elements, (<html>, <head>), but they also exist as objects
because I see on reference sites that they have methods, properties, events,
etc. So they''ve got to be child objects of some other object higher in the
hierarchy. Right? And there has to be some way to address them. Right?

For instance -- on the MSDN site, the docs say that the "innerText" property
of the "html" object, "Sets or retrieves the text between the start and end
tags of the object." OK -- using javascript, how do I "set" or "retrieve"
that property?

"window.html.innerText" doesn''t work. Neither does
"window.document.hml.innerText". Is there an object higher than the window
object that "html" object is a child of?

Any help greatly appreciated. I''ve been staring at this *^#(%^ monitor for
about 8 hours now and my eyeballs are aching.

解决方案

Peter wrote:

But -- I can''t find a way to address the "html" or the "head" objects. I
know they''re HTML elements, (<html>, <head>), but they also exist as objects
because I see on reference sites that they have methods, properties, events,
etc. So they''ve got to be child objects of some other object higher in the
hierarchy. Right? And there has to be some way to address them. Right?


This works for me in Opera 9

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
</head>
<body>
<script type="text/javascript">
var html = document.getElementsByTagName(''html'')[0];
for (var p in html) {
document.write(p+''<br>'');
}
</script>
</body>
</html>

For instance -- on the MSDN site, the docs say that the "innerText" property
of the "html" object, "Sets or retrieves the text between the start and end
tags of the object." OK -- using javascript, how do I "set" or "retrieve"
that property?

This works for me in Opera 9 to see the innerHTML. I don''t know when
setting the innerHTML of the html element would be a good idea.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<script type="text/javascript">
window.onload=function() {
alert(document.getElementsByTagName(''html'')[0].innerHTML);
};
</script>
</head>
<body>
</body>
</html>
- Peter


Peter wrote:

I''m new at this stuff -- so this is probably an incredibly dopey, newby
question. Please bear with me. I don''t know if it''s a HTML or javascript
question. (Or, if a different area altogether, please steer me to the right
group.)

I can view the members of the "window" object with the following javascript.
It returns all the methods, properties, events, etc.

<script type="text/javascript">
for(i in window)
{
window.document.write(i + "<br />");
}
</script>
I can do the same thing for the "document" object by changing the expression
to read...

<script type="text/javascript">
for(i in window.document)
{
window.document.write(i + "<br />");
}
</script>
And then I can check out an individual property, (example "protocol"), with
the following. It returns "HyperText Transfer Protocol".

<script type="text/javascript">
window.document.write(window.document.protocol);
</script>
So far, so good....

But -- I can''t find a way to address the "html" or the "head" objects. I
know they''re HTML elements, (<html>, <head>), but they also exist as objects
because I see on reference sites that they have methods, properties, events,
etc. So they''ve got to be child objects of some other object higher in the
hierarchy. Right? And there has to be some way to address them. Right?

For instance -- on the MSDN site, the docs say that the "innerText" property
of the "html" object, "Sets or retrieves the text between the start and end
tags of the object." OK -- using javascript, how do I "set" or "retrieve"
that property?

"window.html.innerText" doesn''t work. Neither does
"window.document.hml.innerText". Is there an object higher than the window
object that "html" object is a child of?

Any help greatly appreciated. I''ve been staring at this *^#(%^ monitor for
about 8 hours now and my eyeballs are aching.

1 Download a copy of Firefox.

2 Install with the "Custom Install" option to mark sure DOM Inspector is
checked

3 Or better yet, install the Web Developers Bar extension
https://addons.mozilla.org/firefox/60/

4 Open a web page and use the DOM Inspector to traverse the document
tree and view all the attributes.

An indispensable "learning|debugging" tool
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com



Jonathan N. Little wrote:

Peter wrote:

But -- I can''t find a way to address the "html" or the "head" objects. I
know they''re HTML elements, (<html>, <head>), but they also exist as objects
because I see on reference sites that they have methods, properties, events,
etc. So they''ve got to be child objects of some other object higher in the
hierarchy. Right? And there has to be some way to address them. Right?


1 Download a copy of Firefox.

2 Install with the "Custom Install" option to mark sure DOM Inspector is
checked

3 Or better yet, install the Web Developers Bar extension
https://addons.mozilla.org/firefox/60/

4 Open a web page and use the DOM Inspector to traverse the document
tree and view all the attributes.

Or maybe even better than the DOM inspector is the
http://getfirebug.com plugin.

Peter


这篇关于请问一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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