SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Who Me? JeremyL's Avatar
    Join Date
    Dec 1999
    Location
    Dallas, TX
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code Showing On Page

    Hello,

    I am working on a site for the first time. I noticed that a piece of JS was showing as text in the Yahoo Search Cache and when I tried to run a heatmap test using CrazyEgg the screenshot CrazyEgg captured was only this JS.

    The JS is basically a way for people to click on an image in this Yahoo store and have it open in a pop up window.

    The first thing I did was add <!-- //--> tags around the code because it was missing. The JS code is now missing from the Yahoo cache but CrazyEgg still shows the code in the screen capture and the Yahoo Cache also shows JS errors on this piece of code in the browser. Yahoo cache seems to be adding extra code to this particular piece of code.

    So can you have a look and tell me if you see any bugs? I'm definitally not a JS man.

    Code:
    <script language="javascript">
    <!--
    function CaricaFoto(img, name, imgname, wid, hi){
      foto1= new Image();
      foto1.src=(img);
      foto2= new Image();
      foto2.src=(imgname);
      viewFotos(img, name, imgname, wid, hi);}
    function viewFotos(img, name, imgname, wid, hi){
     features =     "toolbar=no,location=no,directories=no,status=no,menubar=no," +
        "scrollbars=no,resizable=no,width=" + wid + ",height=" + hi;
     dlg = window.open ("","Details",features);
     dlg.document.write("<html><head><ti");
     dlg.document.write("tle>" + name + " Zoom</title></head>");
     dlg.document.write("<body bgcolor=white><center>");
     dlg.document.write("<table width=100&#37; height=100%>");
     dlg.document.write("<tr><td align=center valign=middle>");
     dlg.document.write("<img src=" + imgname + ">");
     dlg.document.write("</td></tr><tr><td align=center valign=middle>");
     dlg.document.write("<img src=" + img + ">");
     dlg.document.write("</td></tr>");
     dlg.document.write("<tr><td align=center valign=middle>");
     dlg.document.write("<a href=# onClick=window.close();>");
     dlg.document.write("<font size=1 face=Arial>Click to close</font></a>");
     dlg.document.write("</td></tr>");
     dlg.document.write("</table></body></html>");
    }
    //-->
    </script>
    The site is http://www.cellular-blowout.com

    Note there are other pieces of JS missing the comment tags and I hadn't added that yet as I was trying to work on the direct problem first. Could those other instances be causing any of this?

    This is what CrazyEgg is returning now and what Yahoo was returning before the comment tags where added.
    " + name + " Zoom"); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write(""); dlg.document.write("Click to close"); dlg.document.write("

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    split title

    Maybe if the title tag wasn't split?

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I noticed that a piece of JS was showing as text in the Yahoo Search Cache...
    Yahoo cache seems to be adding extra code to this particular piece of code.
    Apparently, Yahoo Cache robots scrape your webpage, and then Yahoo Cache adds a bunch of js to the page and displays it on its web page. You can view source in Yahoo Cache and see everything it does to your web page.

    Why do you care?

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,868
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Change the code in your page to:

    Code:
    <script type="text/javascript" src="myjs.js"></script>
    and now add an extra file to your site called "myjs.js" that contains the following:

    Code:
    function CaricaFoto(img, name, imgname, wid, hi){
      foto1= new Image();
      foto1.src=(img);
      foto2= new Image();
      foto2.src=(imgname);
      viewFotos(img, name, imgname, wid, hi);}
    function viewFotos(img, name, imgname, wid, hi){
     features =     "toolbar=no,location=no,directories=no,status=no,menubar=no," +
        "scrollbars=no,resizable=no,width=" + wid + ",height=" + hi;
     dlg = window.open ("","Details",features);
     dlg.document.write("<html><head><ti");
     dlg.document.write("tle>" + name + " Zoom<\/title><\/head>");
     dlg.document.write("<body bgcolor=white><center>");
     dlg.document.write("<table width=100&#37; height=100%>");
     dlg.document.write("<tr><td align=center valign=middle>");
     dlg.document.write("<img src=" + imgname + ">");
     dlg.document.write("<\/td><\/tr><tr><td align=center valign=middle>");
     dlg.document.write("<img src=" + img + ">");
     dlg.document.write("<\/td><\/tr>");
     dlg.document.write("<tr><td align=center valign=middle>");
     dlg.document.write("<a href=# onClick=window.close();>");
     dlg.document.write("<font size=1 face=Arial>Click to close<\/font><\/a>");
     dlg.document.write("<\/td><\/tr>");
     dlg.document.write("<\/table><\/body><\/html>");
    }
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Who Me? JeremyL's Avatar
    Join Date
    Dec 1999
    Location
    Dallas, TX
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried making the whole head part on one line but still no go.

    I'll see what I can do about the external JS but it's complicated because it's in a Yahoo Store and code is everywhere.

    Thanks for the help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •