Problème JS et DOCTYPE
Nico
-
Jichin -
Jichin -
Bonjour,
Je cherchais à faire scroller une pub 160x600 sur la hauteur de mon site, pour ce faire j'ai recuperé ce code JS :
// Fonctions Javascripts
function WindowOnload(f) {
var prev=window.onload;
window.onload=function(){ if(prev)prev(); f(); }
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
// Pub Scroller
function pubscroll_makeVars() {
if(document.all) {
h=".pixelLeft=";
v=".pixelTop=";
dS="";
sdm=".style";
y="document.body.scrollTop";
x="document.body.scrollLeft";
doWidth="document.body.clientWidth";
doHeight="document.body.clientHeight"
object="scrollpub120x600";
} else if(document.getElementById){
v=".top=";
h=".left=";
dS="document.";
sdm=".style";
y="window.pageYOffset";
x="window.pageXOffset";
doWidth="window.innerWidth";
doHeight="window.innerHeight"
object="getElementById(\"scrollpub120x600\")";
}
xyz=400
pubscroll_placeIt()
}
movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
function pubscroll_makeXY(){
innerX= ((eval(doWidth)-750)/2) + 750 + 5;
//if (innerX < 760) innerX = 760;
//innerY=eval(doHeight)-150;
//innerX = 0;
innerY = 10;
yy=eval(y);
xx=eval(x);
ydiff=ystart-yy;
xdiff=xstart-xx;
if ((ydiff<(-1))||(ydiff>(1))) movey=Math.round(ydiff/10),ystart-=movey;
if ((xdiff<(-1))||(xdiff>(1))) movex=Math.round(xdiff/10),xstart-=movex;
eval(dS+object+sdm+v+(ystart+innerY));
eval(dS+object+sdm+h+(xstart+innerX));
setTimeout("pubscroll_makeXY()",25);
//if(document.getElementById) document.getElementById("scrollpub120x600").visibility='show';
MM_showHideLayers('scrollpub120x600','','show');
}
function pubscroll_placeIt(){ ystart=eval(y); xstart=eval(x); ystart=0; xstart=0; }
function pubscroll_init () {
MM_showHideLayers('scrollpub120x600','','hide');
pubscroll_makeVars();
pubscroll_makeXY();
MM_showHideLayers('scrollpub120x600','','show');
};
Le problème c'est que ça ne marche que si j'enleve ma balise doctype, si je la garde, le scroll ne marche pas :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Quelqu'un peut il gentillement m'aider ou m'orienter ?
Merci d'avance
Je cherchais à faire scroller une pub 160x600 sur la hauteur de mon site, pour ce faire j'ai recuperé ce code JS :
// Fonctions Javascripts
function WindowOnload(f) {
var prev=window.onload;
window.onload=function(){ if(prev)prev(); f(); }
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
// Pub Scroller
function pubscroll_makeVars() {
if(document.all) {
h=".pixelLeft=";
v=".pixelTop=";
dS="";
sdm=".style";
y="document.body.scrollTop";
x="document.body.scrollLeft";
doWidth="document.body.clientWidth";
doHeight="document.body.clientHeight"
object="scrollpub120x600";
} else if(document.getElementById){
v=".top=";
h=".left=";
dS="document.";
sdm=".style";
y="window.pageYOffset";
x="window.pageXOffset";
doWidth="window.innerWidth";
doHeight="window.innerHeight"
object="getElementById(\"scrollpub120x600\")";
}
xyz=400
pubscroll_placeIt()
}
movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
function pubscroll_makeXY(){
innerX= ((eval(doWidth)-750)/2) + 750 + 5;
//if (innerX < 760) innerX = 760;
//innerY=eval(doHeight)-150;
//innerX = 0;
innerY = 10;
yy=eval(y);
xx=eval(x);
ydiff=ystart-yy;
xdiff=xstart-xx;
if ((ydiff<(-1))||(ydiff>(1))) movey=Math.round(ydiff/10),ystart-=movey;
if ((xdiff<(-1))||(xdiff>(1))) movex=Math.round(xdiff/10),xstart-=movex;
eval(dS+object+sdm+v+(ystart+innerY));
eval(dS+object+sdm+h+(xstart+innerX));
setTimeout("pubscroll_makeXY()",25);
//if(document.getElementById) document.getElementById("scrollpub120x600").visibility='show';
MM_showHideLayers('scrollpub120x600','','show');
}
function pubscroll_placeIt(){ ystart=eval(y); xstart=eval(x); ystart=0; xstart=0; }
function pubscroll_init () {
MM_showHideLayers('scrollpub120x600','','hide');
pubscroll_makeVars();
pubscroll_makeXY();
MM_showHideLayers('scrollpub120x600','','show');
};
Le problème c'est que ça ne marche que si j'enleve ma balise doctype, si je la garde, le scroll ne marche pas :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Quelqu'un peut il gentillement m'aider ou m'orienter ?
Merci d'avance
A voir également:
- Problème JS et DOCTYPE
- Copiez l'image dans un logiciel d'édition d'images ou un outil en ligne comme js paint ou pixlr e. remplissez les cases en suivant le code couleur. des cases supplémentaires vont se remplir automatiquement. que représente le dessin ? ✓ - Forum Windows
- Arrondi js ✓ - Forum Windows
- Doctype ✓ - Forum HTML
- Remplir une case de tableau avec une couleur grise avec texture de pointillés ✓ - Forum Photoshop
- Reproduction d'un dessin - Forum Graphisme
3 réponses
Salut,
J'ai le même probleme, ca marche sans doctype et avec non , le probleme c'est que j'en ai besoin quand même
pour ie qui pour lui c'est l'inverse , ca marche avec mais sans non , bref quelqu'un a t'il un idée ?
Merci d'avance!
mon code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xml:lang="fr" lang="fr" xml?ns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/feuille.css" media="screen" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
J'ai le même probleme, ca marche sans doctype et avec non , le probleme c'est que j'en ai besoin quand même
pour ie qui pour lui c'est l'inverse , ca marche avec mais sans non , bref quelqu'un a t'il un idée ?
Merci d'avance!
mon code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xml:lang="fr" lang="fr" xml?ns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/feuille.css" media="screen" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->