undefined error on first execution of function

P

preet

On first execution of StartSurf() the siteloc returns undefined

On second excution and after that there is no problem.

StartSurf is called from a button press, which becomes invisible for 30
seconds and then visible again.

Suggest solution.

The code I am using is
=========================
var siteloc;
var siteid;
var nVar;
var sitesurfed;
function StartSurf()
{
document.getElementById('surf21').style.visibility='hidden';
nVar = 30;
callSite()

if (siteloc = "")
{
exitSurf()
}
else
{
callTimer()
}
}

function callTimer()
{
if (nVar >= 0)
{
T1.innerHTML = "<b><font color='#FFFFFF'>" + nVar + "</font></b>";
nVar = nVar - 1;
Timer()
}
else
{
document.getElementById('surf21').style.visibility='visible';
}
}

function Timer()
{
window.setTimeout("callTimer()", 1000);
}

function callSite()
{
var file = 'surfdb.asp?T=' + Date();
getSurf(file)

var msg1 = "<b><font color='#FFFFFF'><a style='color: #FFFFFF;
font-size: 10pt; font-weight: ";
msg1 = msg1 + "bold' target='_blank' href='" + siteloc + "'>Open
Site</a></font></b>";
T2.innerHTML = msg1;

var msg5 = "<b><font color='#FFFFFF'>Surfed: " + sitesurfed +
"</font></b>";
T5.innerHTML = msg5;

var msg2 = "<b><font color='#FFFFFF'><a style='color: #FFFFFF;
font-size: 10pt; font-weight: ";
msg2 = msg2 + "bold' target='_blank' href='reportabuse.asp?siteid=" +
siteid + "'>Report Abuse</a></font></b>";
T3.innerHTML = msg2;

document.getElementById('surfFrame').src = siteloc;
}

function getSurf(file)
{
var scriptTag = document.getElementById('loadScript');
var head = document.getElementsByTagName('head').item(0)
if(scriptTag) head.removeChild(scriptTag);
script = document.createElement('script');
script.src = file;
script.type = 'text/javascript';
script.id = 'loadScript';
head.appendChild(script)
}

function exitSurf()
{
document.getElementById('surf21').style.visibility='hidden';
document.getElementById('surfFrame').src = "surfcomp.asp?x=" +
Date();
T1.innerHTML = "";
T0.innerHTML = "";

var msg3 = "<b><font color='#FFFFFF'><a style='color: #FFFFFF;
font-size: 10pt; font-weight: ";
msg3 = msg3 + "bold' href='members.asp?x=" + Date() + "'>My
Account</a></font></b>";
T2.innerHTML = msg3;

T3.innerHTML = "";
}
====================



--------------------------
My websites
http://www.eecpworld.com/
http://www.indiapropertyhome.com/
http://www.wahmdirect.com/
http://www.indianmatrimonialnet.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top