473,788 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

undefined error on first execution of function

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.getEle mentById('surf2 1').style.visib ility='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.getEle mentById('surf2 1').style.visib ility='visible' ;
}
}

function Timer()
{
window.setTimeo ut("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='reportabu se.asp?siteid=" +
siteid + "'>Report Abuse</a></font></b>";
T3.innerHTML = msg2;

document.getEle mentById('surfF rame').src = siteloc;
}

function getSurf(file)
{
var scriptTag = document.getEle mentById('loadS cript');
var head = document.getEle mentsByTagName( 'head').item(0)
if(scriptTag) head.removeChil d(scriptTag);
script = document.create Element('script ');
script.src = file;
script.type = 'text/javascript';
script.id = 'loadScript';
head.appendChil d(script)
}

function exitSurf()
{
document.getEle mentById('surf2 1').style.visib ility='hidden';
document.getEle mentById('surfF rame').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.a sp?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/

*** Sent via Developersdex http://www.developersdex.com ***
Aug 20 '06 #1
1 1560
preet said the following on 8/20/2006 2:26 PM:
On first execution of StartSurf() the siteloc returns undefined
That's because it is undefined. It is initialized but it is still undefined.
On second excution and after that there is no problem.
Because afterwards it is defined.
StartSurf is called from a button press, which becomes invisible for 30
seconds and then visible again.
Suggest solution.
First suggestion: Do some reading, starting with this groups FAQ and the
Best Practices document, both are in my signature.

Second suggestion: Stop using IE only shortcut coding.

Third suggestion: Stop coding in HTML3.2
Fourth suggestion: Properly delimit your signature.
Fifth suggestion: Find a better Usenet provider than devex
Sixth suggestion: Post a URL to your modified code that doesn't use
HTML3.2, doesn't use IE only shortcut coding (I refer to it as lazy-coding).

Need more suggestions?

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2583
by: shablool | last post by:
Hi all, Two distinct compilers give different output for the following code: #include <iostream> #include <string> int main(void) { std::string s("0124"); s.replace(0, 3, s).replace(s.size(), 6, s);
25
3101
by: Nitin Bhardwaj | last post by:
Well, i'm a relatively new into C( strictly speaking : well i'm a student and have been doing & studying C programming for the last 4 years).....and also a regular reader of "comp.lang.c" I don't have a copy of ANSI C89 standard,therefore i had to post this question: What is the difference between "unspecified" behaviour & "undefined" behaviour of some C Code ??
49
14530
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
17
3351
by: yb | last post by:
Hi, Looking for clarification of undefined variables vs. error in JavaScript code. e.g. <script> alert( z ); // this will be an error, i.e. an exception </script>
28
7414
by: robert | last post by:
In very rare cases a program crashes (hard to reproduce) : * several threads work on an object tree with dict's etc. in it. Items are added, deleted, iteration over .keys() ... ). The threads are "good" in such terms, that this core data structure is changed only by atomic operations, so that the data structure is always consistent regarding the application. Only the change-operations on the dicts and lists itself seem to cause problems...
1
1798
by: Noggon | last post by:
Maybe I'm stupid, but I can't find out what is wrong, can anyone help? I keep getting the function first as being undefined for some reason I don't get. I'm trying to use setTimeout() to pause execution so that an image in my web page is switched every two seconds for another. switch(pic_catagory)
45
4863
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to "new Array() vs " question or to the array performance, I dared to move it to a new thread. Gecko takes undefined value strictly as per Book 4, Chapter 3, Song 9 of Books of ECMA :-)
3
4141
by: Anonymous Infidel - Aborted Islam with a hanger | last post by:
I have two classes(class A, class main). class main uses a pointer to class A and class A uses a global pointer to main. My problem is I keep getting these errors: :( a.h(12) : error C2027: use of undefined type 'main' a.h(4) : see declaration of 'main' a.h(12) : error C2227: left of '->SomeDriver' must point to class/ struct/union/generic type How do I fix this?
33
2846
by: coolguyaroundyou | last post by:
Will the following statement invoke undefined behavior : a^=b,b^=a,a^=b ; given that a and b are of int-type ?? Be cautious, I have not written a^=b^=a^=b ; which, of course, is undefined. I am having some confusion with the former statement! Also, state the reason for the statement being undefined!
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.