473,756 Members | 4,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript confirmation dialog


Hello,

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

**

<form method="post" action="mail.ph p" onSubmit="javas cript: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 9299
VK
On May 21, 3:44 pm, Tomislav <josip_mill...@ yahoo.comwrote:
I tried to use "javascript:ret urn confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.ph p" onSubmit="javas cript: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:ret urn confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.ph p" onSubmit="javas cript: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**********@y ahoo.comwrote:
On May 21, 3:44 pm, Tomislav <josip_mill...@ yahoo.comwrote:
>I tried to use "javascript:ret urn confirm();" function in following
manner ( triggered by form onSubmit event ):

**

<form method="post" action="mail.ph p" onSubmit="javas cript: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...@i nvalid.invalidw rote:
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="javasc ript: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="javascrip t: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="javasc ript: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...@i nvalid.invalidw rote:
>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="javasc ript: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="javascri pt: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="userAb ort: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
2726
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: when the user clicks a button in the main window, a dialog window pops up. In the dialog the user enters a university to search for. When the string is submitted, the dialog then shows all the matches found in the database. The user picks one and...
8
1543
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 are two things I need to get rid of though. One, this code keeps the calling window open (i.e., when you click on the URL, a new IE window opens--which is fine--but I can't seem to get the code right to close it. This is the Javascript I have...
1
2566
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 the program must call my user-defined function to delete the row from database. The problem is I do not know how to create a confirm on deletes in a datagrid.
6
1944
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: myNextButton.Attributes.Add("onclick", "return confirm('Are you sure you want finish this test?');") to attach a popup box to a button. The problem is that the buttons only say OK and Cancel. OK will take me to the event tied to the button and Cancel,
4
8521
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 code if the confirmation is positive. I can associate the JavaScript with the button using the Attributes property and get the confirmation dialog to appear but the button control always executes.
1
1935
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 SelectedItem.Cells.Text, and then uses a stored procedure to delete the record. I need to wire up a javascript confirmation dialog (Are you sure you want to delete this record? Yes/No) to it. Any suggestions on how to do this?
2
8989
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 event, I need to do some processing and, if it succeeds, popup a confirmation dialog and redirect to a different page. How can I do this? Here's some pseudo-code:
2
3993
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 <Enter> on the keybord to do the OK operation or click the X in the right top of the dialog to close the dialog. I'm currently using: var agree = confirm("Are you sure you want to "+ action +" the following job definition groups?" + "\\n" +...
2
3729
by: jitendrajoy | last post by:
yes/no confirmation dialog box change defualt value of confirmation dialog box ok/cancel help me
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.