Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 19th, 2007, 03:49 AM
Authorized User
Join Date: Jun 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hericles
Default Object expected error

I have a script in my web page that runs a cross browser transition effect. It works perfectly in FF and well in IE as long as the option to display script errors is off. If script errors is on I get a "Object expected" error relating to this line:

var object = document.getElementById(id).style;

which is generating a null value. Being a perfectionist I would like to be able to remove the bug. The line of code belongs to this function which checks for the various browser transition functions:

//change the opacity for different browsers
function changeOpac(opacity, id) {

    var object = document.getElementById(id).style;
    object.opacity = (opacity / 95);
    object.MozOpacity = (opacity / 95);
    object.KhtmlOpacity = (opacity / 95);
    object.filter = "alpha(opacity=" + opacity + ")";

id refers to the image element the effect is applied to. opacity is a number defining the current level of opacity.
Any help would be much appreciated.
Thank you,

\"I will prepare and one day my chance will come.\"
Old July 19th, 2007, 10:21 AM
Authorized User
Join Date: Jun 2007
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts

Hi hericles

It seems that no element with given "id" exists in your document. Send your entire code. It could be more helpful

Ehsan Zaery Moghaddam

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Object Expected error on mouseover event nrlahoti ASP.NET 2.0 Professional 10 March 15th, 2008 11:30 AM
Object expected darkhalf Javascript 1 September 28th, 2006 05:32 PM
Object Expected!! Apocolypse2005 Javascript 0 July 3rd, 2006 12:23 PM
error on page: object expected eggoose Javascript 5 April 19th, 2006 02:14 AM
run time error: Object expected shoakat Classic ASP Databases 5 September 22nd, 2004 03:17 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.