[thelist] Re: javascript debug (easy)

Tyme newsgroups at no-pun.com
Mon Jun 6 13:11:35 CDT 2005


Yikes!  Okay, here is what I am using (HTML page):

<p align="center" class="center"><b>
[<a href="https://boomersrentals.c2.ixwebhosting.com/orderform.asp" 
target="_blank" onclick="return openOrderForm();" title="Online ordering 
reserved for weekly rentals only.">Online Order Form</a>]
</b></p>

Per the suggestions (ext .js file):
------------------------------------------

function openOrderForm() {

    var agree=confirm("Online ordering is reserved for weekly rentals only. 
Please phone for daily orders. Thank you!");

    if (agree)
    {
       window.open('https://boomersrentals.c2.ixwebhosting.com/orderform.asp','OrderForm','scrollbars=yes,toolbar=no,directories=no,menubar=yes,resizable=yes,status=yes,width=300,height=400,screenX=0,screenY=0,top=0,left=0');
    } // end if

    return agree;
}

I do not rely upon javascript, hence the target="_blank".  [In my early 
newbie days, Jeff Howden's scolding taught me well.]  The javascript is a 
mere convenience for opening the window in a smaller size.  And, now the 
addition of letting the user know not to bother if...

I always thought that one uses "return false" after the HTML's function call 
in order to invoke the target attribute if JS is not installed.  So, its 
omission there threw me a bit.  In general, it seems so much more intuitive 
to say:
    if "OK" button clicked (true) do this [open window/file/orderform]
    else
    [do nothing]

But, at this point, because I am on to something else, I would just settle 
for a conclusion about the last line:  "return agree" or "return false"?

Thank you all.

T--

----- Original Message ----- 
From: "Phil Turmel" <philip at turmel.org>
To: <thelist at lists.evolt.org>
Sent: Monday, June 06, 2005 1:30 PM
Subject: Re: [thelist] Re: javascript debug (easy)


> T--,
>
> Don't dismiss Matt's solution too quickly...  John missed an important 
> part of it: If the original function returns (true), after already running 
> a window.open() method, then both the new window and the original window 
> will go to the new location.  Changing 'return false' to 'return agree' is 
> wrong.
>
> Matt's code has the advantage of permitting graceful fallback when 
> JavaScript is disabled.  In general, if an 'onclick' handler uses 
> window.open, it must return false to avoid doubling up.  In the case of a 
> false from confirm(), the handle must also return false to avoid opening 
> the page.
>
> If the application requires JavaScript for proper operation, put a url for 
> some kind of "JavaScript Required" error page in the link itself, and the 
> correct page in the onclick handler.




More information about the thelist mailing list