473,406 Members | 2,217 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,406 software developers and data experts.

getting 'has no properties' error with document.write()....

function saveState() {
document.write (" | <a href = 'myhomepage.asp?
view=mhp&amp;action=save&amp;pb=");
document.write (document.phone.style.display.value);

document.write ("'>save view</a>");

};
creates an error at this (>) line.

function showhide (item) {
var objid = document.getElementById(item);
var imgid = document.getElementById(item+'i');
var imgidMinusSrc = '/images/furniture/minus.gif';
var imgidPlusSrc = '/images/furniture/plus2.gif';
if (objid.style.display == 'inline') {
objid.style.display = 'none';
imgid.src = imgidPlusSrc;
if (item == 'hpleftcolhl') {
objid.style.width = '4px';
document.getElementById('hpleftcol').style.width = '6px';
document.getElementById('showtime').style.display =
'none';
}
}
else {
objid.style.display = 'inline';
imgid.src = imgidMinusSrc;
if (item == 'hpleftcolhl') {
objid.style.width = '160px';
document.getElementById('hpleftcol').style.width =
'160px';
document.getElementById('showtime').style.display =
'inline';
}
}
};
this one however works fine, and both use the same object?
I've tried using document.getElementById('phone').style.display
but with same result.

now, the saveState function is simply some inline script to build an <a
href> , whereas the showhide one is triggered from an onclick.
Jul 23 '05 #1
5 1732


s_m_b wrote:
function saveState() {
document.write (" | <a href = 'myhomepage.asp?
view=mhp&amp;action=save&amp;pb=");
document.write (document.phone.style.display.value);


document.write ("'>save view</a>");

};
creates an error at this (>) line.


If the function is executed after the page has been loaded the first
document.write clears the existing page and then document.phone does no
longer exist. Thus the problem is likely that you use document.write
after the page has been loaded.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Lee
s_m_b said:

function saveState() {
document.write (" | <a href = 'myhomepage.asp?
view=mhp&amp;action=save&amp;pb=");
document.write (document.phone.style.display.value);

document.write ("'>save view</a>");

};
creates an error at this (>) line.


document.write() clears the current contents of the document,
so by that second line, document.phone no longer exists.

Jul 23 '05 #3
Lee <RE**************@cox.net> wrote in news:d0*********@drn.newsguy.com:
s_m_b said:

function saveState() {
document.write (" | <a href = 'myhomepage.asp?
view=mhp&amp;action=save&amp;pb=");
document.write (document.phone.style.display.value);

document.write ("'>save view</a>");

};
creates an error at this (>) line.


document.write() clears the current contents of the document,
so by that second line, document.phone no longer exists.


hum.....
would window.document.url = ...
be an alternative for getting the page to reload?
Jul 23 '05 #4
In article <Xn**********************************@216.196.97.1 38>,
sm********@hotmail.com enlightened us with...

hum.....
would window.document.url = ...
be an alternative for getting the page to reload?


Reloading will also wipe your variables. In fact, it wipes everything and
gets the page fresh.

But if you want it:
window.location.reload();

--
--
~kaeli~
Time flies like an arrow. Fruit flies like a banana.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #5
s_m_b wrote:
Lee <RE**************@cox.net> wrote in news:d0*********@drn.newsguy.com:

s_m_b said:
function saveState() {
document.write (" | <a href = 'myhomepage.asp?
view=mhp&amp;action=save&amp;pb=");

> document.write (document.phone.style.display.value);

document.write ("'>save view</a>");

};
creates an error at this (>) line.


document.write() clears the current contents of the document,
so by that second line, document.phone no longer exists.

hum.....
would window.document.url = ...
be an alternative for getting the page to reload?


It seems that you are trying to create a URL based on current
page settings for the user to click on. If that is the case,
then use DOM methods to write the link, not document.write.

Alternatively, create your HTML as one string, then write the
entire thing in one go so that by the time document.write clears
the page, you've already used your in-page values:
var aHTML = ' | <a href = "myhomepage.asp?'
+ 'view=mhp&amp;action=save&amp;pb='
+ document.phone.style.display.value
+ '">save view</a' + '>';
document.write(aHTML);

--
Rob
Jul 23 '05 #6

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

Similar topics

6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
7
by: GfxGuy | last post by:
I've seen this problem posted a million times, but I've read through all of them and can't figure out what I'm doing wrong. Simple example (this is the whole file, no editing): ---------- ...
12
by: Adam Lipscombe | last post by:
Folks, I need to get the contents of a form attribute. In Read/Write mode this is field, so I can use getElementById("name").value In ReadOnly this is just plain text, so I can use...
28
by: Stefan Mueller | last post by:
I can display the value of the following input box with alert(parent.MyFrame.document.MyForm.MyInput.value); But if the frame, the form or the input box doesn't exist I get of course an error...
1
by: rajesh | last post by:
var fixedX = -1 // x position (-1 if to appear below control) var fixedY = -1 // y position (-1 if to appear below control) var startAt = 0 // 0 - sunday ; 1 - monday var showWeekNumber =...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
6
by: =?Utf-8?B?dGhsMTAwMA==?= | last post by:
Hi NG, i need to list the logonHours for a specific user. I'm trying to convert code from vbscript (is working) to vb.net, but the vb.net code does not work. Here are the code listings: 1:...
6
by: DRS.Usenet | last post by:
When I run alert("page contents:" + content.document.documentElement.innerHTML); I am able to pull the content. I see something like this page contents:<head><title>A Title</title>...
5
by: Locke | last post by:
Hi, What is the correct way to get the dimensions of the displayable window? I.e. I don't want the border or the toolbar to be included in the height or width. I want to request an image from...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.