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

Why is this short and simple function not working in MSIE?

function confirmDelete(id, title) {
confirmation=confirm('Delete " '+title+' "?');
if (confirmation) {
window.location='delete.php'; // NOTHING HAPPENS
}
}

Tried it with window.location.href, tried putting alert() before and
after window.location (alert box pops up but it won't redirect)...
works ok in Firefox and Opera. Doesn't work in MSIE 6 on XP SP1.


TIA

Jul 23 '05 #1
4 1256
Lee
a-**@consultant.com said:

function confirmDelete(id, title) {
confirmation=confirm('Delete " '+title+' "?');
if (confirmation) {
window.location='delete.php'; // NOTHING HAPPENS
}
}

Tried it with window.location.href, tried putting alert() before and
after window.location (alert box pops up but it won't redirect)...
works ok in Firefox and Opera. Doesn't work in MSIE 6 on XP SP1.


Give it a full url.

Jul 23 '05 #2
There is no full url... except http://localhost/ :-)

But I found the problem...

I called the function from an onclick event in a link <a> tag but the
href value containted another javascript call, like

<a href="javascript: somefunction()"
onclick="confirmDelete()">Delete</a>

Apparently, this doesn't work in MSIE if the function confirmDelete()
calls the window.location method.

Dumb ass MSIE...

rgds.

Jul 23 '05 #3
Lee
a-**@consultant.com said:

There is no full url... except http://localhost/ :-)

But I found the problem...

I called the function from an onclick event in a link <a> tag but the
href value containted another javascript call, like

<a href="javascript: somefunction()"
onclick="confirmDelete()">Delete</a>

Apparently, this doesn't work in MSIE if the function confirmDelete()
calls the window.location method.
Dumb ass MSIE...


Be that as it may, you should [almost] never do either of those things.
Avoid the javascript: pseudo-protocol unless the javascript code that
it defines returns the new HTML content of the page, and don't change
the window.location in the middle of an event that is intended to change
the page content.

Jul 23 '05 #4
<a-**@consultant.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
There is no full url... except http://localhost/ :-)

But I found the problem...

I called the function from an onclick event in a link <a> tag but the
href value containted another javascript call, like

<a href="javascript: somefunction()"
onclick="confirmDelete()">Delete</a>

Apparently, this doesn't work in MSIE if the function confirmDelete()
calls the window.location method.
No, it has no problems with that at all.

<a href="noJS.html"
onclick="
if (!confirmDelete())
somefunction();
return false;
">Delete</a>
-- OR --
<a href="noJS.html"
onclick="
!confirmDelete() && someFunction();
return false;
">Delete</a>
<script type="text/javascript">
function confirmDelete() {
if (confirm('Do you really want to delete blah?')) {
location = 'about:blank';
return true;
}
return false;
}
</script>
Dumb ass MSIE...


Do you blame the hammer when you hit your thumb too?

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

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

Similar topics

5
by: Keiron Waites | last post by:
This is my code: <script language="JavaScript" type="text/javascript"> <!-- desc_switch = 0; function description (desc,type) { // onBlur alert(desc_switch) if (type == 3) {...
4
by: Buzzy | last post by:
Hi all, I'm trying to use this : <html> <head> <style type="text/css"> @page { margin:10cm } </style> </head>
2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer:...
10
by: Brett | last post by:
This code is supposed to work in Netscape 4+ and IE 4+. It works fine in IE but in Netscape 7.2, I get a blank page. Any suggestions? Thanks, Brett <html> <head>
12
by: Oliver Knoll | last post by:
Ok, I've searched this group for Big/Little endian issues, don't kill me, I know endianess issues have been discussed a 1000 times. But my question is a bit different: I've seen the follwing...
8
by: Droopy | last post by:
I am making a managed C++ wrapper for calling legacy C++ code from C#. I don't understand what's wrong with following code : __gc public class SerialBuffer { private: unsigned...
9
by: xiao | last post by:
It always dumped when I tried to run it... But it compiles OK. What I want to do is to do a test: Read information from a .dat file and then write it to another file. The original DAT file is...
23
by: =?Utf-8?B?TWlrZTE5NDI=?= | last post by:
This is an example that is supposed to work in VB http://support.microsoft.com/kb/175512/en-us After spending a couple of hours downloading and installing VB Express 2008 after someone told me it...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.