DOCTYPE HTML public on a Web page will cause part of the page's events not to trigger

Source: Internet
Author: User
Tags array definition contains sin versions
Page | page

Recently busy to do JS, in JS useful to mouse some of the events, usually I was the mouse event included in a JS file call
<script type= "Text/javascript" src= "Js/sb_cd.js" ></script>

A mouse event that contains the following mouse effect can cause an event trigger:js/sb_cd.js
JavaScript Document

var sb_cd_a_colour= ' fff000 ';
var sb_cd_b_colour= ' 00ff00 ';
var sb_cd_c_colour= ' ff00ff ';
var sb_cd_size=120;

var sb_cd_ydummy=new Array (), sb_cd_xdummy=new Array (), Sb_cd_xpos=0,sb_cd_ypos=0,sb_cd_ thisstep=0;sb_cd_step=0.6;
if (document.layers) {
window.captureevents (event.mousemove);
function Sb_cd_nsmouse (evnt) {
Sb_cd_xpos = window.pageyoffset+evnt.pagex+6;
Sb_cd_ypos = window.pageyoffset+evnt.pagey+16;
}
Window.onmousemove = Sb_cd_nsmouse;
}
Else if (document.all)
{
Function sb_cd_iemouse () {
Sb_cd_xpos = document.body.scrollleft+event.x+6;
Sb_cd_ypos = document.body.scrolltop+event.y+16;
}
Document.onmousemove = Sb_cd_iemouse;
}

function Sb_cd_swirl () {
for (i = 0; i < 3; i++)
{
Sb_cd_ydummy[i]=sb_cd_ypos+sb_cd_size*math.sin ((1*math.sin (sb_cd_thisstep)/10) +i*2) *Math.sin ((sb_cd_ThisStep )/4);
Sb_cd_xdummy[i]=sb_cd_xpos+sb_cd_size*math.cos ((1*math.sin (sb_cd_thisstep)/10) +i*2) *Math.sin ((sb_cd_ThisStep )/4);
}
Sb_cd_thisstep+=sb_cd_step;
SetTimeout (' Sb_cd_swirl () ', 10);
}

var sb_cd_amount=10;
if (document.layers) {
for (i = 0; i < Sb_cd_amount; i++)
{
document.write (' <layer name=sb_cd_nsa ' +i+ ' top=0 left=0 ' width= +i/2+ ' height= ' +i/2+ ' bgcolor= ' ' +sb_cd_a_Colour+ ') ></layer> ');
document.write (' <layer name=sb_cd_nsb ' +i+ ' top=0 left=0 ' width= +i/2+ ' height= ' +i/2+ ' bgcolor= ' ' +sb_cd_b_Colour+ ') ></layer> ');
document.write (' <layer name=sb_cd_nsc ' +i+ ' top=0 left=0 ' width= +i/2+ ' height= ' +i/2+ ' bgcolor= ' ' +sb_cd_c_Colour+ ') ></layer> ');
}
}
else if (document.all) {
document.write (' <div id= "Sb_cd_odiv" style= "position:absolute;top:0px;left:0px" > "
+ "<div id=" Sb_cd_idiv "style=" position:relative ">");
for (i = 0; i < Sb_cd_amount; i++)
{
document.write (' <div id=sb_cd_x style= ' position:absolute;top:0px;left:0px;width: ' +i/2+ '; height: ' +i/2+ '; Background: ' +sb_cd_a_colour+ '; font-size: ' +i/2+ ' ></div> ');
document.write (' <div id=sb_cd_y style= ' position:absolute;top:0px;left:0px;width: ' +i/2+ '; height: ' +i/2+ '; Background: ' +sb_cd_b_colour+ '; font-size: ' +i/2+ ' ></div> ');
document.write (' <div id=sb_cd_z style= ' position:absolute;top:0px;left:0px;width: ' +i/2+ '; height: ' +i/2+ '; Background: ' +sb_cd_c_colour+ '; font-size: ' +i/2+ ' ></div> ');
}
document.write (' </div></div> ');
}
function Sb_cd_prepos () {
var sb_cd_ntscp=document.layers;
var Sb_cd_msie=document.all;
if (document.layers) {
for (i = 0; i < Sb_cd_amount; i++)
{
if (I < sb_cd_amount-1)
{
sb_cd_ntscp[' Sb_cd_nsa ' +i].top=sb_cd_ntscp[' Sb_cd_nsa ' + (i+1)].top;sb_cd_ntscp[' Sb_cd_nsa ' +i].left=sb_cd_ntscp[ ' Sb_cd_nsa ' + (i+1)].left;
sb_cd_ntscp[' SB_CD_NSB ' +i].top=sb_cd_ntscp[' SB_CD_NSB ' + (i+1)].top;sb_cd_ntscp[' SB_CD_NSB ' +i].left=sb_cd_ntscp[ ' SB_CD_NSB ' + (i+1)].left;
sb_cd_ntscp[' sb_cd_nsc ' +i].top=sb_cd_ntscp[' sb_cd_nsc ' + (i+1)].top;sb_cd_ntscp[' SB_CD_NSC ' +i].left=sb_cd_ntscp[ ' SB_CD_NSC ' + (i+1)].left;
}
Else
{
sb_cd_ntscp[' Sb_cd_nsa ' +i].top=sb_cd_ydummy[0];sb_cd_ntscp[' Sb_cd_nsa ' +i].left=sb_cd_xdummy[0];
sb_cd_ntscp[' SB_CD_NSB ' +i].top=sb_cd_ydummy[1];sb_cd_ntscp[' SB_CD_NSB ' +i].left=sb_cd_xdummy[1];
sb_cd_ntscp[' sb_cd_nsc ' +i].top=sb_cd_ydummy[2];sb_cd_ntscp[' sb_cd_nsc ' +i].left=sb_cd_xdummy[2];
}
}
}
else if (document.all) {
for (i = 0; i < Sb_cd_amount; i++)
{
if (I < sb_cd_amount-1)
{
Sb_cd_msie.sb_cd_x[i].style.top=sb_cd_msie.sb_cd_x[i+1].style.top;sb_cd_msie.sb_cd_x[i].style.left=sb_cd_ Msie.sb_cd_x[i+1].style.left;
Sb_cd_msie.sb_cd_y[i].style.top=sb_cd_msie.sb_cd_y[i+1].style.top;sb_cd_msie.sb_cd_y[i].style.left=sb_cd_ Msie.sb_cd_y[i+1].style.left;
Sb_cd_msie.sb_cd_z[i].style.top=sb_cd_msie.sb_cd_z[i+1].style.top;sb_cd_msie.sb_cd_z[i].style.left=sb_cd_ Msie.sb_cd_z[i+1].style.left;
}
Else
{
SB_CD_MSIE.SB_CD_X[I].STYLE.TOP=SB_CD_YDUMMY[0];SB_CD_MSIE.SB_CD_X[I].STYLE.LEFT=SB_CD_XDUMMY[0];
SB_CD_MSIE.SB_CD_Y[I].STYLE.TOP=SB_CD_YDUMMY[1];SB_CD_MSIE.SB_CD_Y[I].STYLE.LEFT=SB_CD_XDUMMY[1];
SB_CD_MSIE.SB_CD_Z[I].STYLE.TOP=SB_CD_YDUMMY[2];SB_CD_MSIE.SB_CD_Z[I].STYLE.LEFT=SB_CD_XDUMMY[2];
}
}
}
SetTimeout ("Sb_cd_prepos ()", 10);
}
function Sb_cd_start () {
Sb_cd_swirl (), Sb_cd_prepos ()
}
Window.onload=sb_cd_start;

The code for the page is as follows:
When you open a DW, you usually have this predefined code first, look at the first line
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Untitled Document </title>

<body>
<script type= "Text/javascript" src= "Js/sb_cd.js" ></script>
</body>


The problem has been looking for a long time, and I don't know where it is. Later found to be the first sentence of DW generated code
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"http://www.w3.org/TR/html4/loose.dtd" >
Make this mouse event not run. , it is stated here that the following mouse events must follow the rules of this DTD document.
Some definitions in the No event are not followed, so this mouse event does not trigger and does not complain.

This is the official definition of DOCTYPE HTML public

! DOCTYPE

Specifies the document type definition (DTD) that the HTML document follows.

What's new in Microsoft ®internet Explorer 6

You can use this declaration to switch Internet Explorer 6 and later versions to standard compatibility mode.

Grammar

Html Top-level element Availability "register//organization/Type label//Definition language" URL "

Possible values

top-level element < The font color= "#000080" specifies the top-level element type declared in the DTD. This corresponds to the declared SGML document type. default. Html. " TD style= "BORDER:0;PADDING:0;" >
html
availability < The font color= "#000080" to specify whether the formal public identifier (FPI) is a publicly accessible object or a system resource.
public default. An object that can be publicly accessed.
system system resources, such as local files or URLs.
register < Font color= "#000080" Specifies whether the organization is registered by the International Organization for Standardization (ISO).
+ default. The organization name is registered.
- organization name not registered. The Internet Engineering Task Force (IETF) and the World Wide Web Consortium (WWW) are not registered ISO organizations.
organization < Font color= "#000080" > designation indicates responsibility by! The name of the group or organization that DOCTYPE declares the creation and maintenance of a referenced DTD, that is, Ownderid. IETF. " TD style= "BORDER:0;PADDING:0;" >
IETF
w3c w3c.
Type Specifies the exposed text class, which is the referenced object type.
Dtd Default. Dtd.
Label Specifies the public text description, which is the unique descriptive name for the exposed text that is referenced. The version number can be attached later.
Html Default. Html.
definition < The font color= "#000080" to specify the document type definition.
frameset frameset document.
strict
transitional FrameSet element.
Language Specifies the public text language, which is the natural language encoding system used to create the referenced object. The language definition has been written as an ISO 639 language code (uppercase two letters).
En Default. English.
Url Specifies the location of the referenced object.

Comments

This declaration must appear at the beginning of the document and appear in the HTML label before.

! The DOCTYPE element does not need to close the label.

This element is available in theHTML of Microsoft ®internet Explorer 3.0.

You can use this statement to switch to the strict standard compatibility mode in Internet Explorer 6 and later versions. If you want to open this switch, please include it at the top of your document ! DOCTYPE Declaration, specify a valid label in the Declaration and, in some cases, specify a definition and/or URL. The following table lists the switch conditions for the standard compatibility mode.

The
DOCTYPEURL appears URL Not present
DOCTYPE not present Off Off
HTML (No version) Off Off
HTML 2.0 Off Off
HTML 3.0 Off Off
HTML 4.0 Open Open
HTML 4.0 Frameset Open Off
HTML 4.0 Transitional Open Off
HTML 4.0 Strict Open Open
Xhtml Open Open
Xml Open Open
Unrecognized DOCTYPE Open Open
note that in standard compatibility mode, it is not guaranteed to remain compatible with other versions of Internet Explorer. When standard compatibility mode is turned on, the rendering behavior of the document may be different from future versions of Internet Explorer. This mode should not be used if the content is inherently fixed (such as burning on a CD).

Example

The following example shows how to use ! DOCTYPE declares the DTD that the specified document complies with and switches Internet Explorer 6 and later to standard compatibility mode.

The declarations in the following example specify compliance with the HTML 4.0 DTD. The second declaration specifies "Strict". The first type of declaration is not specified. Both of these declarations will switch Internet Explorer 6 and later versions to standard compatibility mode.

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.0//en" ><! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 strict//en" >

The declarations in the following example specify compliance with the "transitional" HTML 4.0 DTD. The second declaration specifies the URL of the DTD. The first type of declaration is not specified. The second statement will switch Internet Explorer 6 and later versions to standard compatibility mode. The first kind of declaration does not.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" ><! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"     "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >

Standard Information



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.