Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
window.location not working
Old 06-28-2004, 11:38 AM window.location not working
Novice Talker

Posts: 5
Trades: 0
Can anyone suss this out for me?...

its a confirm box used on an asp created page: -

// to call the funtion
<a href="&"javascript:void(null)"&" onClick="&"confirm_delete("& newsId &"); return false"&">Delete</a>

// the function
<script language="javascript">
function confirm_delete (newsId)
{
var message = "Are you sure you want to delete?";
var return_value = confirm(message);

if ( return_value == true )
{
window.location.href="http://www.google.com";
}
}
</script>

the window.location just doesn't work, I hear the clicking sound but nothing happens, if I change to window.open it works fine, but I obviously dont want it in a new window. I have tried messing around with various syntax but not really sure what to do.

Any ideas very much appreciated

dan
DannyT is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-28-2004, 12:29 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Looking at the Location object, I don't think that you need to reset the href property. Just assign the new URL to window.location.

Code:
window.location = 'http://www.google.com/';
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-28-2004, 02:01 PM
Novice Talker

Posts: 5
Trades: 0
I still get nothing? I am really confused on such a simple thing, I can't find any other similar problems in any forums which leads me to believe I'm doing something even more basic wrongly, but can't think what?

Thanks for your help
DannyT is offline
Reply With Quote
View Public Profile
 
Old 06-28-2004, 02:12 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
I think it might be because you're returning false, try returning true.

Code:
onclick="confirm_delete(newsId); return true">
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-28-2004, 02:17 PM
Novice Talker

Posts: 5
Trades: 0
OK gettin somewhere, I managed to get it to work now with, as you said:
Code:
window.location = 'http://www.google.com/';
BUT, how do i link to a relative page? e.g.
Code:
window.location = 'samplepage.htm';
DannyT is offline
Reply With Quote
View Public Profile
 
Old 06-28-2004, 06:45 PM
Novice Talker

Posts: 5
Trades: 0
its totally weird

window.open="filename.htm"; is fine
window.location="http://www.domain.com; is fine
but
window.location="filename.htm" doesn't work
window.location="http://www.domain.com/filename.htm" doesn't work either

??????????????????????????????
DannyT is offline
Reply With Quote
View Public Profile
 
Old 06-29-2004, 01:19 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
I usually use

HTML Code:
<script>
location.href="http://www.webmaster-talk.com";
</script>
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to window.location not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21710 seconds with 12 queries