Click to See Complete Forum and Search --> : What is this doing?
Webskater
07-04-2003, 08:54 AM
Could anyone tell me what the bold code is doing? Trapself is set to false at the top of the page.
<SCRIPT FOR=document EVENT="onclick">
var objSrc = event.srcElement;
var objWin = window.location;
if (objSrc.tagName=='A' && TrapSelf == false)
{
var loc1 = objSrc.href.search(/\./);
if (loc1 != -1)
var ref1 = objSrc.href.slice(0,loc1);
SlankenOgen
07-04-2003, 09:05 AM
var loc1 = objSrc.href.search(/\./);
is searching for a "."
if (loc1 != -1)
var ref1 = objSrc.href.slice(0,loc1);
if it is found make ref1 = loc1;
chrismartz
07-04-2003, 09:07 AM
looks to me that it is trying to find some sort of other page but cannot tell without more code
Webskater
07-04-2003, 09:31 AM
Thanks for your replies. More of the code is below. As I understand it what is happening is ...
If the thing clicked on in this document is a hyperlink and the hyperlink address is the same as the address of the window that is currently open - then the page is submitting to itself and PageEdited is set to false - which allows the submission to occur (in a different function) What I don't understand is:
What value will loc1 have if a '.' is found in the href?
and what does:
objSrc.href.slice(0,loc1);
actually return?
Will it return the part of the hyperlink up to the first occurrence of a '.'?
<SCRIPT FOR=document EVENT="onclick">
var objSrc = event.srcElement;
var objWin = window.location;
if (objSrc.tagName=='A' && TrapSelf == false)
{
var loc1 = objSrc.href.search(/\./);
if (loc1 != -1)
var ref1 = objSrc.href.slice(0,loc1);
var loc1 = objWin.href.search(/\./);
if (loc1 != -1)
var ref2 = objWin.href.slice(0,loc1);
if (ref1 == ref2) PageEdited = false;
}
</SCRIPT>