Click to See Complete Forum and Search --> : Resubmission of Form Doesn't Run Javascript


zylstra
05-10-2003, 07:43 PM
Javascript code that receives information from a textbox and that I use to populate frames only works the first time I use it.

The code is:

<script language=javascript>
function showInfo() {
parent.altavista.document.location.href = 'http://www.altavista.com/web/results?kgs=0&kls=1&avkw=xytx&q=link%3Awww.' + document.domainform.domain.value;
parent.alexa.document.location.href = 'http://www.alexa.com/data/details/traffic_details?q=&url=' + document.domainform.domain.value;
document.domainform.textbox.value = 'check '+document.domainform.domain.value;
return false;
}
</script>

But I don't think the code is the problem. I seems that the javascript doesn't run code if it thinks that it has already been run. Is there some way to reset it? I've already tried reseting the form with the Javascript code, but that didn't work.

The frames with code can be seen at http://www.globalnotion.com/website.htm .

Thank you for all of your help,
zylstra

Charles
05-10-2003, 10:08 PM
Originally posted by Dave Clark
I don't know if this is part of the problem, or not, but the following is technically an invalid reference:

parent.altavista.document.location.href

it should, instead, be:

parent.altavista.location.hrefStrictly speaking, however, it's not invalid for JavaScript 1.1 and later but it drives JavaScript purists nuts. Back in the days of JavaScript 1.0 we had document.location, document.URL and Window.location. At this stage the first two were essentially the same, read only properties that represented the actual URL of the document. Window.location was, and remains, an object that represents the requested URL. And at this stage there was no such thing as document.location.href but there was a Window.location.href. Note that at this stage you could assign to Window.location.href and to Window.location but not to document.location or document.URL. JavaScript 1.1 tried to clean this mess up a bit by depricating document.location in favour of document.URL. However, they didn't just drop document.location like the should have, to keep the old web sites working, they made it a synonym for Window.location which more or less returns the same result when read from. And it means that document.location.href is sadly the same thing as Window.location.href. On older browsers it will not work and you have been officially instructed to not use it and it is an abomination so please do not use it.

zylstra
05-11-2003, 01:09 PM
Dave and Charles,

Thank you both for such helpful advice and instruction. I only hope that I can help you some day also.

Thanks,
zylstra

zylstra
05-11-2003, 01:50 PM
Yes, it is, thanks.