Doctype使用会杀死一些javascripts [英] Doctype use kills some javascripts

查看:95
本文介绍了Doctype使用会杀死一些javascripts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将过渡性文档类型添加到我的社区

网站上的天气页面时,我放弃了某些Js脚本,但不是所有脚本。


这让我感到很困惑。


主菜单由js脚本提供支持,即使用eh

doctype也可以运行。


但是,一旦我在页面上放置过渡性文档类型

,浮动菜单就不起作用了。在

右侧处理浮动页面顶部图标的js脚本存在问题。


我创建了具有新名称的天气页面版本您可以

访问它们而不会干扰我的访客数量。


没有doctype和INTERNAL JS的功能页面就在这里它可以工作:
http://www.wgtn.net/weather/weather_without_doctype.htm


带有doctype和INTERNAL JS的非功能页面在这里:
http://www.wgtn.net/weather/weather_with_doctype.htm


我想,也许是制作js脚本EXTERNAL将解决

问题。


但这也不起作用。哦,dang。


没有doctype和EXTERNAL JS的功能页面在这里:
http://www.wgtn.net/weather/weather_...externaljs.htm


非-duntioning页面包含doctype和EXTERNAL JS在这里:
http:/ /www.wgtn.net/weather/weather_...externaljs.htm


我不想放弃我的浮动菜单。


我希望能够使用doctype以便我的页面验证。这个

帮助我确保它们尽可能地跨浏览器。


有没有其他人遇到过与JS脚本的冲突使用

doctype并有解决方案或解决方法?

When I add a transitional doctype to the weather page on my community
website, I loose certain Js scripts, but not all of them.

This puzzles me.

The main menu is powered by a js script and seems to function even with eh
doctype.

But, the floating menu doesn''t function once I put a transitional doctype of
the page. The js script that handles the floating top of page icon on the
right side is problematic.

I have created version of the weather page with new names so that you can
access them w/o interfering with my visitor counts.

The funtioning page without doctype and INTERNAL JS is here and it works:
http://www.wgtn.net/weather/weather_without_doctype.htm

The non-funtioning page with doctype and INTERNAL JS is here:
http://www.wgtn.net/weather/weather_with_doctype.htm

I thought, perhaps that making the js script EXTERNAL would solve the
problem.

But this does not work either. Oh, dang.

The funtioning page without doctype and EXTERNAL JS is here:
http://www.wgtn.net/weather/weather_...externaljs.htm

The non-funtioning page with doctype and EXTERNAL JS is here:
http://www.wgtn.net/weather/weather_...externaljs.htm

I dont want to give up my floating menus.

I would like to be able to use a doctype so that my pages validate. This
helps me feel sure that they are cross-browser as much as I can do.

Has anyone else run up against this conflict with JS scripts and use of
doctype and have a solution or workaround?


推荐答案

rfr schreef:
rfr schreef:

我希望能够使用doctype以便我的页面验证。这个

帮助我确保它们尽可能地跨浏览器。


有没有其他人遇到过与JS脚本的冲突使用

doctype并有解决方案或解决方法吗?
I would like to be able to use a doctype so that my pages validate. This
helps me feel sure that they are cross-browser as much as I can do.

Has anyone else run up against this conflict with JS scripts and use of
doctype and have a solution or workaround?



只需附上以下内联脚本:

//<![CDATA [

...你的剧本......

//]]>

JW

Simply enclose your inline scripts with the following:

// <![CDATA[
... your script ...
// ]]>
JW


5月27日上午11点10分,Janwillem Borleffs写道:
On May 27, 11:10 am, Janwillem Borleffs wrote:

rfr schreef:
rfr schreef:

>我希望能够使用doctype以便我的页面验证。这有助于我确信它们是我可以做的跨浏览器。

有没有其他人遇到与JS脚本的冲突
和使用doctype和有解决方案或解决方法?
>I would like to be able to use a doctype so that my pages
validate. This helps me feel sure that they are cross-browser
as much as I can do.

Has anyone else run up against this conflict with JS scripts
and use of doctype and have a solution or workaround?



只需附上以下内联脚本:


//<![CDATA [

...你的剧本...

//]]>


Simply enclose your inline scripts with the following:

// <![CDATA[
... your script ...
// ]]>



难道这个特殊的咒语只与HTML页面相关吗

希望欺骗加价验证人认为它们是XHTML,或

,用于附录C XHTML页面,作为HTML和XHTML,并且在内容协商之后会花费


中几乎不会发生的事情)现实并使脚本复杂化到甚至W3C

放弃内容协商并仅将页面作为HTML提供时,他们将这些页面用于b $ b脚本)?


OP中没有证据表明插入的DOCTYPE只是一个HTML DOCTYPE,而且浏览器最有可能遭受的损失

来自CSS兼容模式的变化是IE,IE将永远不会解释任何直接渲染XHTML的文件,赔率非常低

SCRIPT元素的内容未被解释因为CDATA在这里是一个

的问题。


最多与添加DOCTYPE相关的ikely问题需要

在分配 - style - 属性时提供CSS单位值,并且

IE'切换''root ''节点来自 - document.body - 没有DOCTYPE

到 - document.documentElement - 有一个。

Isn''t that particular incantation only relevant for HTML pages that
wish to fool a mark-up validator into thinking that they are XHTML, or
for Appendix C XHTML pages that are served as both HTML and XHTML
following content negotiation (something that almost never happens in
reality and complicates scripting to such a degree that even the W3C
abandon content negotiation and serve pages only as HTML when they
script those pages)?

There is no evidence in the OP that the DOCTYPE being inserted is
anything but an HTML DOCTYPE, and as the browser most likely to suffer
from a change in the CSS compatibility mode is IE, and IE will never
interpret any document it directly renders XHTML the odds are very low
that contents of SCRIPT elements not being interpreted as CDATA is an
issue here at all.

The most likely issues related to the addition of a DOCTYPE is need to
provide CSS unit values when assigning to - style - properties, and
IE''s switching of ''root'' node from - document.body - without a DOCTYPE
to - document.documentElement - with one.


Henry写道:
Henry wrote:

5月27日上午11点10分,Janwillem Borleffs写道:
On May 27, 11:10 am, Janwillem Borleffs wrote:

> rfr schreef:
>rfr schreef:

>>我希望能够使用doctype以便我的页面验证。这有助于我确信它们是我可以做的跨浏览器。

有没有其他人遇到与JS脚本的冲突
和使用doctype和有解决方案或解决方法?
>>I would like to be able to use a doctype so that my pages
validate. This helps me feel sure that they are cross-browser
as much as I can do.

Has anyone else run up against this conflict with JS scripts
and use of doctype and have a solution or workaround?


只需用以下内容附上您的内联脚本:

//<![CDATA [
...您的脚本...
//]]>

Simply enclose your inline scripts with the following:

// <![CDATA[
... your script ...
// ]]>



难道这个特殊的咒语只与HTML页面相关吗

希望欺骗加价验证人认为它们是XHTML,


Isn''t that particular incantation only relevant for HTML pages that
wish to fool a mark-up validator into thinking that they are XHTML,



完全没有。它与所有HTML 4.01文档相关,不遵循HTML 4.01规范,附录B,第3.5节中的建议

及以下内容:

http:// www.w3.org/TR/REC-html40/appe...s.html#hB.3.3


或附录C XHTML页面同时用作HTML和XHTML
or for Appendix C XHTML pages that are served as both HTML and XHTML



它与所有符合XHTML 1.0规范第4节中的建议的XHTML文档相关,但是不要按照最后的

提到的替代方案:

http://www.w3.org/TR/2000/REC-xhtml1-20000126/#diffs


以下内容协商
following content negotiation



内容协商不是必须的ssarily涉及到这里。

Content negotiation is not necessarily involved here.


(实际上几乎不会发生的事情
(something that almost never happens in reality



然而它确实发生了。

Yet it does happen.


并使脚本复杂程度达到甚至W3C

放弃内容协商并仅将页面作为HTML提供

脚本那些页面)?
and complicates scripting to such a degree that even the W3C
abandon content negotiation and serve pages only as HTML when they
script those pages)?



你能提供一些证据来支持这些陈述吗?


(完全确认其余的。)

PointedEars

-

var bugRiddenCrashPronePieceOfJunk =(

navigator.userAgent.indexOf(''MSIE 5'') != -1

&& navigator.userAgent.indexOf(''Mac'')!= -1

)// Plone,register_function.js:16

Could you please provide some proof to back up these statements?

(Full ACK to the rest.)
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf(''MSIE 5'') != -1
&& navigator.userAgent.indexOf(''Mac'') != -1
) // Plone, register_function.js:16


这篇关于Doctype使用会杀死一些javascripts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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