By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a


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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.