#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0

    Unhappy


    Please review the code below. It has javascript rollovers and uses a php session. The code gives me a javascript error in IE 5.5. The error says "Error: Expected ')'. I do not get this error in Netscape 4.73. I found that if I remove the javascript rollover functions that I have in the header, I do not get an error. The page also works fine in IE 5.5 if only the php is removed. Is there something I should know about adding php to a page containing javascript functions that will produce errors in IE 5.5?

    <?
    session_start();

    session_register('counter');

    $counter++;

    echo("$counter");

    ?>

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v3.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); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>

    <body bgcolor="#FFFFFF" onLoad="MM_preloadImages('../wtaimages/bandson.gif','../../wtaimages/bandson.gif','../../wtaimages/djson.gif','../../wtaimages/classon.gif','../../wtaimages/specon.gif','../../wtaimages/videon.gif','../../wtaimages/conton.gif','../wtaimages/homeon.gif','../wtaimages/djson.gif')">
    <div align="center">
    <table border="0" cellspacing="0" cellpadding="0" align="center" width="640">
    <tr>
    <td width="60"><a href="../index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image16','','../wtaimages/homeon.gif',1)"><img name="Image16" border="0" src="../wtaimages/homeoff.gif"></a></td>
    <td width="70"><a href="../bands/index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','../wtaimages/bandson.gif',1)"><img name="Image10" border="0" src="../wtaimages/bandsoff.gif"></a></td>
    <td width="30"><a href="../djs/index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','../wtaimages/djson.gif',1)"><img name="Image14" border="0" src="../wtaimages/djsoff.gif" width="60" height="25"></a></td>
    <td width="110"><a href="../classical/index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','../wtaimages/classon.gif',1)"><img name="Image9" border="0" src="../wtaimages/classoff.gif"></a></td>
    <td width="115"><a href="../specialty/index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','../wtaimages/specon.gif',1)"><img name="Image8" border="0" src="../wtaimages/specoff.gif"></a></td>
    <td width="115"><a href="../video/index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','../wtaimages/videon.gif',1)"><img name="Image12" border="0" src="../wtaimages/videooff.gif"></a></td>
    <td width="191"><a href="index.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','../wtaimages/conton.gif',1)"><img name="Image13" border="0" src="../wtaimages/conton.gif" width="100" height="25"></a></td>
    </tr>
    </table>
    </div>

    </body>
    </html>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Russia.
    Posts
    4
    Rep Power
    0
    Try to move the following line:

    echo("$counter");

    to somewhere between <body bgcolor="#ffffff" text="#000000" id=all> and </body> tags. (escaping it with <? ?> of course)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Russia.
    Posts
    4
    Rep Power
    0

    Exclamation


    Ooops! It seems that vBulletin has a bug! In the previous message I didn't wrote all that "bgcolor", "text", "id" in the "body" tag...
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    I moved echo("$counter"); as you suggested, but I still get the same error as before.

  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    I found a strange clue. When I selected View Source in IE 5.5, I found that a session id was added to all lines of code that contain links (shown below) in the JavaScript Rollovers. Remember, the error and the strange code only occur when I start a session using IE 5.5. When I refresh IE 5.5, the error and strange code go away. The error and strange code never occur with Netscape 4.73.

    1
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x="a[i])&&x.oSrc;i++)" x.src="x.oSrc;
    "
    }

    function MM_preloadImages() { //v3.0
    var d="document;" if(d.images){ if(!d.MM_p) d.MM_p="new" Array();
    var i,j="d.MM_p.length,a=MM_preloadImages.arguments;" for(i="0;" i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src="a[i];}}
    "
    }

    function MM_findObj(n, d) { //v3.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); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>

    <body bgcolor="#FFFFFF" onLoad="MM_preloadImages('../wtaimages/bandson.gif','../../wtaimages/bandson.gif','../../wtaimages/djson.gif','../../wtaimages/classon.gif','../../wtaimages/specon.gif','../../wtaimages/videon.gif','../../wtaimages/conton.gif','../wtaimages/homeon.gif','../wtaimages/djson.gif')">
    <div align="center">
    <table border="0" cellspacing="0" cellpadding="0" align="center" width="640">
    <tr>
    <td width="60"><a href="../index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image16','','../wtaimages/homeon.gif',1)"><img name="Image16" border="0" src="../wtaimages/homeoff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c"></a></td>
    <td width="70"><a href="../bands/index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','../wtaimages/bandson.gif',1)"><img name="Image10" border="0" src="../wtaimages/bandsoff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c"></a></td>
    <td width="30"><a href="../djs/index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','../wtaimages/djson.gif',1)"><img name="Image14" border="0" src="../wtaimages/djsoff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" width="60" height="25"></a></td>
    <td width="110"><a href="../classical/index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','../wtaimages/classon.gif',1)"><img name="Image9" border="0" src="../wtaimages/classoff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c"></a></td>
    <td width="115"><a href="../specialty/index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','../wtaimages/specon.gif',1)"><img name="Image8" border="0" src="../wtaimages/specoff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c"></a></td>
    <td width="115"><a href="../video/index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','../wtaimages/videon.gif',1)"><img name="Image12" border="0" src="../wtaimages/videooff.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c"></a></td>
    <td width="191"><a href="index.htm?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','../wtaimages/conton.gif',1)"><img name="Image13" border="0" src="../wtaimages/conton.gif?PHPSESSID=7485ab84e70ff5e7855f0a41d446c21c" width="100" height="25"></a></td>
    </tr>
    </table>
    </div>

    </body>
    </html>
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    If you have php compiled with --enable-trans-sid and the browser does not accept your session cookie, then PHP will automagically append all query strings in your scripts with the session id. It would appear your IE5.5 does not accept cookies while your Netscape does.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    Thanks for the information. I also noticed that numerous quotes (") were automatically added to the code I listed. I think the added quotes are giving me the javascript error. Why do you think this is happening?

IMN logo majestic logo threadwatch logo seochat tools logo