Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error : object expected

Status
Not open for further replies.

cluksha

Programmer
Mar 11, 2004
19
US
For the life of me I can't find my typing error or programming error here...

I am calling the script like this.
Code:
<script type="text/javascript" src="../js/global.js"></script>
in the head..
then
Code:
<script language="javascript" type="text/javascript">email_custom('emaillink','mydomain.com','','','me')</script>
inline.

the global.js reads:
Code:
function email_custom(class,domain,text,subject,to){
	if (text){
		text=text
	}else{
		text=to+"@"+domain
	}
	if (subject){subject="?SUBJECT="+subject};
		var email="<a href='";
		email += "mailto:";
		email += to;
		email += "@"+domain;
		if(subject){email += subject;}
		email += "'";
		if(class){email += " class='"+class+"'"};
		email += ">";
		email += text;
		email +="</a>";
		
		document.write(email);
}

I keep getting Object expected line 59. Line 59 is the call to the script
Code:
<script language="javascript" type="text/javascript">email_custom('emaillink','mydomain.com','','','me')</script>

I'm stumped.
thanks all.
Chris

Chris Luksha
Echo Web Services
Making Your Website Resound
 
This works fine for me:
Code:
<html>
<head>
<script type="text/javascript">

function email_custom(class,domain,text,subject,to){
    if (text){
        text=text
    }else{
        text=to+"@"+domain
    }
    if (subject){subject="?SUBJECT="+subject};
        var email="<a href='";
        email += "mailto:";
        email += to;
        email += "@"+domain;
        if(subject){email += subject;}
        email += "'";
        if(class){email += " class='"+class+"'"};
        email += ">";
        email += text;
        email +="</a>";

        document.write(email);
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">email_custom('emaillink','mydomain.com','','','me')</script></body>
</html>
My guess is that the path to your js file path is wrong so the object in this case your "email_custom" is not loading.


recheck your path
Code:
<script type="text/javascript" src="[COLOR=red]../js/global.js"[/color]></script>
 
FUny thing is - I did just the same thing you did for testing - I plopped it all in the same file and ouila - it didn't work.

I will cut and paste your code and see what I get.

thanks

Chris Luksha
Echo Web Services
Making Your Website Resound
 
Interestingly - It was simply not working in IE 7. It works fine in Firefox - which I test in usually - but I switched over to IE on this one when I started getting another error.

I am stumped :)

Chris Luksha
Echo Web Services
Making Your Website Resound
 
class is a keywrod in ie.. change your parameter name.
 
class is a keywrod in ie
The oddest thing is that I swore I tested that exact issue last night.

I just tried it again and it is working fine. Thanks for all the input everyone!

Chris

Chris Luksha
Echo Web Services
Making Your Website Resound
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top