473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Javascript onLoad error "Object doesn't support this action"

I have the following script in an html page:

function goToPosition()
{
varGoTo = document.write(document.cookie("Position"));
document.scrollTo(0, varGoTo);
}
</head>
<body onload="goToPosition()">

When I put the onload="goToPosition()" in, I get the error message
"object doesn't support this action". I've also tried putting in after
the </body> tag as another script...no go.

I'm setting the cookie with these lines in another function:
varScroll = document.body.scrollTop; document.cookie("Position") =
varScroll;

Any clues/suggestions greatly appreciated. I recently posted a similar
question, but rearranged how I was doing it, still no luck, so I'm
trying again.

Thanks.
Kathy
Jul 20 '05 #1
4 13721
KathyB wrote:
I have the following script in an html page:

function goToPosition()
{
varGoTo = document.write(document.cookie("Position"));
document.scrollTo(0, varGoTo);
}
</head>
<body onload="goToPosition()">

When I put the onload="goToPosition()" in, I get the error message
"object doesn't support this action". I've also tried putting in after
the </body> tag as another script...no go.

Any clues/suggestions greatly appreciated. I recently posted a similar
question, but rearranged how I was doing it, still no luck, so I'm
trying again.


A document.write after the document has fully loaded will _replace_ the current document with the new
content, you can either place an empty div in the body and update the innerHTML or innerText propertly of
that div, or use window.alert to show the information, but you cannot use document.write.

--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #2
"KathyB" <Ka**********@attbi.com> wrote in message
news:75**************************@posting.google.c om...
I have the following script in an html page:

function goToPosition()
{
varGoTo = document.write(document.cookie("Position"));
document.scrollTo(0, varGoTo);
scrollTo is a global function (property of the window object) so:-

window.scrollTo(0, varGoTo);
- or -
scrollTo(0, varGoTo);

-would work better. But - document.write( ... ) - in/after the onload
event (when the document has been closed) will clear the current
document and replace it (along with JavaScript functions and variables.
}
</head>
<body onload="goToPosition()">

When I put the onload="goToPosition()" in, I get the
error message "object doesn't support this action". I've
also tried putting in after the </body> tag as another
script...no go.
After the body tag is an invalid location for a script tag, just before
the body tag would be OK (and a much better place to be doing -
document.write( ... ) - as the document will not yet have been closed.
I'm setting the cookie with these lines in another
function:
varScroll = document.body.scrollTop;
The scroll offset is not always available as body.scrollTop. On many
browsers that value is available as window.pageYOffset and on IE 5.5+
browsers the scrollTop value should be read from
document.documentElement instead of document.body when the page is in
"standards" mode (document.compatMode == 'CSS1Compat'):-

var varScroll = 0;
if(typeof pageYOffset == 'number'){
varScroll = pageYOffset;
}else if((document.compatMode)&&
(document.compatMode == 'CSS1Compat')&&
(document.documentElement)){
varScroll = document.documentElement.scrollTop;
}else if(document.body){
varScroll = document.body.scrollTop;
}
document.cookie("Position") = varScroll;

<snip>

document.cookie - is a string property of the document object and not a
function so this syntax is incorrect.

Richard.
Jul 20 '05 #3
Thanks for the responses. I put the original together from other
posts/examples, but now realize that I should not have used
document.write...I just need to get the cookie value to set as the
varScroll value, not actually write it?

I still can't seem to get the cookie value (never used it before!).

Re: document.cookie - is a string property of the document object and
not a function so this syntax is incorrect...I've actually seen this
used in example(s) so now I'm confused yet again.

Thanks for the help!

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:3f***********************@news.frii.net...
<snip>
Re: document.cookie - is a string property of the document
object and not a function so this syntax is incorrect...I've
actually seen this used in example(s) so now I'm confused yet
again.


Server-side ASP JScript, I think, has a cookie function on either the
request or response objects (or both) that you may have seen used in
this way. For client side cookie work you will have to find your own set
of cookie functions. You might have a look at:-

<URL: http://jibbering.com/faq/#FAQ4_4 > and follow the link in that
section as it leads to a page with example cookie functions and some
explanation of them and their use.

Richard.
Jul 20 '05 #5

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

Similar topics

1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
0
by: Martin Widmer | last post by:
Hello again! I have a datagridview control on my form and am using VS.Net 2005. One column is set up as combo box column, and when I try to set the datasource for that combobox column at design...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
4
by: Phil | last post by:
Hi, This code gives an javascript error: "Object required" and never let see the Alert window. in code-behind: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As...
2
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I'm doing a server side automation(I know it's bad but..) and its working fine locally and when accessing it from a remote machine using web browser is was giving me this error"Retrieving the COM...
3
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I'm doing a server side automation(I know it's bad but..) and its working fine locally and when accessing it from a remote machine using web browser is was giving me this error"Retrieving the COM...
11
by: narpet | last post by:
Hello all, I'm hoping somebody can help me with this. I have an app that I've been developing in MS Visual Studio 2005 Pro, C#. I have connectivity to a SQL server database. All of the sudden,...
2
by: =?Utf-8?B?U3dhcHB5?= | last post by:
hi, I am working on application in this i am using two files. In first (consider A) file i am calling the function of other file (consider B). In that function of file B i am calling the method...
3
by: Sarah | last post by:
Hi - Please be gentle. I am quite new to visual basic, but I have been going through tutorials and reading up. I found a code snippet on the internet that I wanted to see if I could re-purpose...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.