Forum Moderators: open

Message Too Old, No Replies

Help with the functionality of a piece of code

         

Digimon

9:52 am on Jan 12, 2007 (gmt 0)

10+ Year Member



Dear all,
I am struggling to understand something. Maybe someone here can help me out. There is this site which is apparently designed using frames. If I type the homepage in my browser and view the source code I can see a frameset. However it is set in a way where only will file will display (frameset rows="0,*"). If I navigate around the site the url and title will stay unchanged for the rest of the session. All normal so far.

However, I suspect there is something weird in a piece of javascript code in the home page because:
1. If I roll my mouse over the link in the menu using explorer the links will not display in the bar at the bottom (next to the little explorer icon).

2. If I search the site in google I can see many indexed with individual titles and no-frameset codes (the snippets are unique). The urls are the same as in the links in the menu. If I click those links from the homepage, the title and code will be the same as the home page (frameset). That doesn't seem to be accurate.

3. In fact, if I switch javascript off and click the result in google, I will be able to see the unique title and code as in the google SERP.

4. Nevertheless, with js still switched off, if I type the url for the home page in my browser the script will execute anyway (!) displaying the url, the title and the home page code for the rest of the session, independently of the internal pages I visit.

What works for any of the internal pages should also work for the home page, shouldn't it?

See below the suspecious script just in case this makes any sense :P


<script language="Javascript"><!--
document.domain="urlomitted.co.uk";
//--></script>
<script language=JavaScript>
<!--
var browser_type = navigator.appName;
var version = parseInt(navigator.appVersion, 10);
if ( browser_type == "Netscape" )
{
if ( version <= 4 )
document.location.href='er04/catalog/htdocs/incompatible.htm';
}
else if ( browser_type == "Microsoft Internet Explorer" )
{
if ( version <= 3 )
document.location.href='er04/catalog/htdocs/incompatible.htm';
}
// -->
</script>
<script language="JavaScript">
<!--
function sel(x,y)
{
var z=(""+Math.round((new Date()).getTime()/100)%1000000000);
var o="000000000";
var qb=""+(document.referrer);
qb=escape(qb);
z+=o.substring(0,9-z.length);
z+=z;
var u = null;
var upre = "http://store.urlomitted.co.uk/catalog/BasketUpdate?";
if(x=='buy')
{
u=upre+"item="+y+"&finish=yes&id="+z;
}
if(x=='add')
{
u=upre+"item="+y+"&id="+z;
updateBasket();
}
if(x=='view')
{
u=upre+"id="+z+(qb.length>0?"&qb="+qb:"");
}
if(x=='select')
{
u=upre+"item="+y+"&select=yes&id="+z;
}
if(u!=null)
{
if(navigator.userAgent.indexOf('MSIE 3')==-1)
top.storetop.location.replace(u);
else
top.storetop.location=u;
}
}

function updateBasket()
{
try
{
function swapcontent(src,trgt,s)
{
var ss=s;
var ts=s;
if( s=="YourBasketLink" )
ss="CheckoutLink";
var se=null;
var te=null;

if(navigator.userAgent.indexOf('MSIE')>=0)
{
se=src.all[ss];
te=trgt.all[ts];
}
else
{
se=src.getElementById(ss);
te=trgt.getElementById(ts);
}
if(se!=null && te!=null)
{
if(s=="YourBasketLink")
te.innerHTML=se.innerHTML.replace(/Checkout/,'YOUR BASKET');
else
te.innerHTML=se.innerHTML;
}
}
var sm = storemain.document;
var st = storetop.document;
swapcontent(st,sm,"Signin");
swapcontent(st,sm,"NumberOfItems");
swapcontent(st,sm,"CheckoutLink");
swapcontent(st,sm,"BasketImg");
swapcontent(st,sm,"YourBasketLink");
}
catch (e)
{
}
}

function checkframe()
{
for (var i=0; i<top.frames.length; i++)
{
if (top.frames[i].name == "storetop")
return true;
}
return false;
}

function checkimage()
{
for (var i=0; i<top.storetop.document.images.length; i++)
{
if (top.storetop.document.images[i].name == "logo")
return true;
}
return false;
}

function changeImage(x)
{
}
function getlogo()
{
return logo;
}
//-->
</script>

Rambo Tribble

1:34 am on Jan 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't quite follow your explanation, but the JavaScript doesn't appear particularly unusual at first wash. I'd suggest using Firefox to examine the site. If you right-click within a frame with FF, you can examine the source for only that frame. Perhaps that will help.

Digimon

6:30 pm on Jan 16, 2007 (gmt 0)

10+ Year Member



Sorry if I haven't explained myself clearly. It is quite a strange thing.
In fact, forget all the background info and please let me know what the script is supposed to do.

The first script is certainly a browser version checker. I get that. It is the second one that I don't understand.
Thanks again!

Rambo Tribble

4:22 am on Jan 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what all the machinations are in aid of, but it appears just to be code associated with a shopping cart.