parent.location problem with MSIE

M

Martin Herrman

Hi all,

I'm quite new to javascript. I'm using the following code:

<a href="javascript: void(0)" OnClick="if(confirm('Are you sure you want
to delete the following items? sv650.jpg,.'))
parent.location='index.php?option=modulemanager&module=11&suboption=show&suboption2=delete&ID3=,52&ID=21&gallerypage=1';">Delete
selected items</a>

Using Mozilla or Netscape (Linux or Windows), this works fine. Using
MSIE, the new url is not loaded.

Any ideas why this happens and any solution?

much thanks in advance,

Martin
 
E

Evertjan.

Martin Herrman wrote on 10 nov 2003 in comp.lang.javascript:
OnClick="if(confirm('..........

Do away with the "if". You need a fals/true return.

<a href="javascript:void(0)"
OnClick="return confirm('Do you want to delete these items?')"
parent.location='index.php?....';">
Delete
</a>
 
M

Martin Herrman

Do away with the "if". You need a fals/true return.

<a href="javascript:void(0)"
OnClick="return confirm('Do you want to delete these items?')"
parent.location='index.php?....';">
Delete
</a>

Stupid me. Thanks for your help!
 
S

Stuart Palmer

Martin, what error do you get? What is not happening?

I have done:

<script language="javascript">
function deletefile()
{
if(confirm('Are you sure you want to delete the following items?
sv650.jpg,.'))
{
parent.location='http:\/\/www.yahoo.com';
return true;
}
else
{
return false;
}
}
</script>

<a href="javascript: void(0)" onmousedown="return(deletefile());">Delete
selected items</a>

and this works in ie 5.5. The bast way is to create a function I think.

Hope that helps.

Stu
 
E

Evertjan.

Martin Herrman wrote on 10 nov 2003 in comp.lang.javascript:
Stupid me. Thanks for your help!

On second view, I am partly wrong.

This should work:

<a href='index.php?....' target="_parent"
OnClick="return confirm('Do you want to delete these items?')">
Delete
</a>

And this:

<script>
function checkifdelete(){
if confirm('Do you want to delete these items?')
parent.location.href='index.php?....';
return false;
}
</script>
<a href="#"
OnClick="return checkifdelete();">
Delete
</a>

In both cases the onclick should return something boolean.

The javascript:void(0) is superfluous,
because it will only be uselessly invoked if javascript is off.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top