What is this codr in frontpage

Discussion in 'HTML & Website Design' started by pixeladd, Mar 21, 2008.

  1. #1
    just looking at the code of my pages in frontpage and noticed this at the top

    function FP_swapImg() {
     var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
     n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
     elm.$src=elm.src; elm.src=args[n+1]; } }
    }
    
    function FP_preloadImgs() {
     var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
     for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
    }
    
    function FP_getObjectByID(id,o) {
     var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
     else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
     if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
     for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
     f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
     for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
     return null;
    Code (markup):

     
    pixeladd, Mar 21, 2008 IP
  2. raymondgill08

    raymondgill08 Peon

    Messages:
    287
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what info are you looking for exactly?
     
    raymondgill08, Mar 21, 2008 IP
  3. pixeladd

    pixeladd Banned

    Messages:
    2,238
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just want to know what this code is for and if i can delete it??
     
    pixeladd, Mar 22, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Looks like the Frontpage version of Dreambeaver's MM_swap. You're going to run into more strangeness if you stay with Frontpage. Even MS abandoned it eventually.

    Anyway, what it looks like it does is change images on something when it's hovered over. A slow, bloated, code-heavy way of doing it. The only advantage to keeping it might be that hover will work on non-links in IE6 (because it needs some sort of scripting help in that department). Otherwise, if that image-change-on-hover isn't happening on the page anymore, delete it. You can use CSS to change background images on :hover or :focus anyway, and if it happens on links (the <a href="#"> part), nothing special is needed for IE6 anyway.
     
    Stomme poes, Mar 22, 2008 IP
  5. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #5
    Not only is it unnecessary Javascript, it is crap Javascript. All you neeed for that is one function to detect the src of an image and change it onmouseover and onmouseou.

    Moral of the story: Uninstall front page, and look at a notepad substitute (Notepad++, Edit+)
     
    blueparukia, Mar 22, 2008 IP