473,385 Members | 1,630 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,385 software developers and data experts.

JavaScript confirmation dialog


Hello,

I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.php" onSubmit="javascript:return
confirm('Do you really want to send this order ?);">

**

When I include Submit button in this form form action should be
performed after "OK" is clicked on confirmation dialog e.g. "mail.php"
should be then executed. Only thing is that it is executed directly
without any confirm windows.

JS is enabled and browser is Firefox 2.0. What is more I frequently use
JS in my designs and this very site I am working on now has plenty of JS
included. That is a bit confusing - that code above does not work.

Did I miss something when I incorporated JS in form ?

Thanks,

Tomislav
May 21 '07 #1
5 9274
VK
On May 21, 3:44 pm, Tomislav <josip_mill...@yahoo.comwrote:
I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.php" onSubmit="javascript:return
confirm('Do you really want to send this order ?);">

**
See my P.S. comment at
http://groups.google.com/group/comp....f9475caf8ee778
While IE tolerates javascript: pseudo-protocol misuse, many other UAs
do not.
May 21 '07 #2
Tomislav <jo***********@yahoo.comwrote:
I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.php" onSubmit="javascript:return
confirm('Do you really want to send this order ?);">

**

When I include Submit button in this form form action should be
performed after "OK" is clicked on confirmation dialog e.g. "mail.php"
should be then executed. Only thing is that it is executed directly
without any confirm windows.

JS is enabled and browser is Firefox 2.0.
Turn on the error console and it will tell you why that didn't work. Or
even better install Firebug and you'll get a nice red error indication in
the status bar which you can click to show the offending line.

Your problem is that you have a missing quote mark at the end of the
parameter to confirm().

You also have a completely spurious label: onsubmit doesn't take a URL:
that 'javascript:' is a label not a protocol. Assuming you didn't intend to
add a 'goto javascript' anywhere in your code you should delete it.
May 21 '07 #3
VK <sc**********@yahoo.comwrote:
On May 21, 3:44 pm, Tomislav <josip_mill...@yahoo.comwrote:
>I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.php" onSubmit="javascript:return
confirm('Do you really want to send this order ?);">

**

See my P.S. comment at
http://groups.google.com/group/comp....f9475caf8ee778
While IE tolerates javascript: pseudo-protocol misuse, many other UAs
do not.
It isn't a protocol, it's a label. Spurious but mostly harmless. Can you
name any javascript implementations which wouldn't accept the label? By
definition they will be broken implementations.
May 21 '07 #4
VK
On May 21, 5:21 pm, Duncan Booth <duncan.bo...@invalid.invalidwrote:
It isn't a protocol, it's a label. Spurious but mostly harmless.
I am taking my hat off over such creative interpretation. Really, all
these years I never thought of onclick="javascript:something()" as of
a Javascript label in front of a statement. I guess such view was
always shadowed by the usage in links like
href="javascript:something()". - I hope there is no doubts that in the
latter case it is pseudo-protocol?

However cool such interpretation would be (and it is cool) in the
original Microsoft proposal - who is the inventor of this syntax - it
is spelled as "place javascript: before your JScript code" so
"javascript:" part is clearly excluded from the code itself - at least
in mind of authors of the proposal. I remind that it is one of ways
Microsoft suggested to use for mixed pages where both VBScript and
JScript are used. If the first script block on the page is VBScript
then all consecutive script blocks w/o explicit type or language
declaration _and_ all intrinsic event handlers on the page will be
parsed using VBScript engine. Naturally if they are written in JScript
the whole page will get broken. The simplest way would be of course to
support meta tag Script-Content-Type but it would be too easy for such
big corporation :-) So they suggested a few alternate solutions for
the developers:
1) If intrinsic event handlers are written in JScript then:
a) ensure that the very first script block on the page is JScript, one
may simply place bogus block before anything else:
<script type="text/javascript"></script>
b) ensure that all consecutive script blocks have type or language
declaration: or at least all blocks using VBScript

2) If the page is a holly mix of VBScript and JScript coding including
intrinsic event handlers - but with VBScript as the default one - then
place a marker in intrinsic event handlers like
onclick="javascript:mycode()"
Respectively they instructed the engine to treat that javascript: as a
marker "JScript code further follows" which is obviously out of any
connection with Javascript labels.

I can tell that IE7 is much smarter than IE4-6 with its code type
detection. Alas I also can tell that javascript: "prefix" in event
handlers had time to become another classical Cargo Cult phenomenon.

May 21 '07 #5
Lee
VK said:
>
On May 21, 5:21 pm, Duncan Booth <duncan.bo...@invalid.invalidwrote:
>It isn't a protocol, it's a label. Spurious but mostly harmless.

I am taking my hat off over such creative interpretation. Really, all
these years I never thought of onclick="javascript:something()" as of
a Javascript label in front of a statement. I guess such view was
always shadowed by the usage in links like
href="javascript:something()". - I hope there is no doubts that in the
latter case it is pseudo-protocol?

However cool such interpretation would be (and it is cool) in the
original Microsoft proposal - who is the inventor of this syntax - it
is spelled as "place javascript: before your JScript code" so
"javascript:" part is clearly excluded from the code itself - at least
in mind of authors of the proposal.
Microsoft took advantage of the existing label syntax to give
special meanings to certain label values. This had the
advantage that any browser that didn't interpret their meaning
would simply ignore it as a valid (albeit useless) label.

onclick="userAbort:self.close()"

is also valid, of course.
--

May 21 '07 #6

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

Similar topics

6
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen:...
8
by: Brent_White_99 | last post by:
I copied the code from another HTML script that someone before me had written. I have no Javascript experience (I'm a VB Programmer/DBA) at all. The code below works to a certain extent. There...
1
by: Mphoza | last post by:
Hi! Programmers,,,,,, Scenario I have a DataGrid with the delete button, If the user delete the row I'd like to show a confirmation dialog box with two buttons(Yes,No). If the user click yes...
6
by: tshad | last post by:
I am trying to set up a Javascript popup box that has a way of sending back a message to asp.net on how to process some data. At the moment I am just doing: ...
4
by: phil | last post by:
Is there an elegant way that I can return a value from a JavaScript function to ASP.NET? I want to have a popup confirmation dialog using JavaScript and only have a button control execute its ASP...
1
by: Joey | last post by:
I am using a datagrid with a SELECT button to determine which record to delete. The code behind pulls the selected item's record number (via a hidden column) in the grid with...
2
by: steggun | last post by:
How To: Popup Confirmation Dialog & Redirect in LinkButton_OnClick Hello All, I have a ASP.NET 2.0 (C#) web form with a LinkButton control. In the server-side code for the LinkButton_OnClick...
2
by: jreedar | last post by:
I have a need to display a confirmation box that allows for a scrollbar since the list of entries is large. You can't find the OK button, because of the too many items in the dialog. You can only hit...
2
by: jitendrajoy | last post by:
yes/no confirmation dialog box change defualt value of confirmation dialog box ok/cancel help me
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.