Re: History Replacement And New Location Combined



David Mark said the following on 7/12/2007 6:28 AM:
On Jul 11, 11:22 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
David Mark said the following on 7/11/2007 7:55 PM:





"Randy Webb" <HikksNotAtH...@xxxxxxx> wrote in message
news:YuednTlhAsRh9gjbRVn_vgA@xxxxxxxxxxxxxx
David Mark said the following on 7/11/2007 7:32 PM:
> In each and every page, I have up to four 'submit' buttons with their
respective onClick event handlers. If I used onSubmit event handler,
it would have to decide what event needs to be serviced, actually
getting me back (through one additional step) to the same logic I've
already applied.
Okay, but instead of:
<form method="get" action="javascript: savePage();"
onSubmit="checkForm();">
Why not something like:
<form method="get" onsubmit="if (checkForm()) savePage(); return false">
<form method="get" action="someFileSoThatNonJSPeopleGoSomewhere.php"
onsubmit="return someFunction()">
function someFunction(){
if(checkForm()){
savePage();
return false;
}
return true;
}
I went over that with him. His is a JS-only app. So he will need to
generate the form with JS and present a NOSCRIPT warning to everyone else.
No, you put the non-JS warning on the page and then you replace it using
JS. If you put it in a noscript element and the script has an error,
then the JS crowd gets nothing.

I don't agree with that.

You are entitled to that opinion just as I am entitled to mine :)

In an HTML document, I say just document.write the form and pair
it with a NOSCRIPT tag.

It is far more reliable to make the noscript block part of the page and then replace it with a form element using script.

In an XHTML document that is actually served as XHTML, I would insert the nodes
that make up the form after the page loads. Under what circumstances
would such a script error?

Hmm. Ever seen a site that uses third party scripts? Think about Google AdSense and many others that you have no control over. If you have one in your page and there is an error in that script, then yours is now broken and your visitor won't see anything at all.

If you do it the other way, you must either wait for the page to load
to replace the warning message or simulate the DOMContentLoaded for
browsers that don't support it (ie put the script near the bottom of
the page, possibly with a timeout and hope for the best.) If you go
with the former method, you get a flash of the warning message, the
latter is a lot of trouble and not foolproof (as few things are with
IE.)

I have never seen a flash of the warning message but I have never put anything other than a short message and no images on the page. Then it loads almost instantly then I place images/forms and other things. But, on a slow computer with a graphics heavy page it could be a problem.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.