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

location.href caching and ASP

i'm passing the asp parameters using the url
current page is files.asp
and I'm using window.location.href=files.asp?action=deletefile to pass the
action to the serverside

My code never got executed (like the page was cached) unless i put
document.write("") before the window.location directive.

Can anyone explain?

Here's the code:
function confirmDelete(x){
var potvrda=confirm("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
trans="files.asp?action="+x;
document.write("")
window.location.href=trans;
}
else {}
}
Jul 23 '05 #1
9 2312
Kreso schrieb:
My code never got executed (like the page was cached)
"Does not work" is a useless error description. [psf 4.11]
Debug your code: <3F**************@PointedEars.de>
unless i put document.write("") before the window.location directive.
It is an assignment statement, not a directive. Get informed about the
programming language you are using: <http://jibbering.com/faq/#FAQ3_2>
[...]
function confirmDelete(x){
var potvrda=confirm("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
Unless you do not require potvrda's value later, you can simplify this:

if (confirm(...))

If you require the value later, you can still remove the "==true".
The variable's value is already a boolean expression.
trans="files.asp?action="+x;
You should use the escape() or encodeURIComponent() methods to escape
the value of x. See <40**************@PointedEars.de> for details.

Besides, you are unnecessesarily defining a global variable without
declaring it first. That is bad style. Use the "var" keyword to
declare and define a local variable instead (var trans = ...).
document.write("")
This statement overwrites the current document. I am astonished that
window.location.href=trans;
is ever executed. Surely it will not in all UAs. Remove it.
}
else {}
An empty "else" block is nonsense. Remove it and the "else" statement.
}


You should watch more for Pretty Printing, especially indentation.
It makes your code easier legible and thus understandable.
PointedEars
Jul 23 '05 #2
Kreso schrieb:
My code never got executed (like the page was cached)
"Does not work" is a useless error description. [psf 4.11]
Debug your code: <3F**************@PointedEars.de>
unless i put document.write("") before the window.location directive.
It is an assignment statement, not a directive. Get informed about the
programming language you are using: <http://jibbering.com/faq/#FAQ3_2>
[...]
function confirmDelete(x){
var potvrda=confirm("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
Unless you do not require potvrda's value later, you can simplify this:

if (confirm(...))

If you require the value later, you can still remove the "==true".
The variable's value is already a boolean expression.
trans="files.asp?action="+x;
You should use the escape() or encodeURIComponent() methods to escape
the value of x. See <40**************@PointedEars.de> for details.

Besides, you are unnecessarily defining a global variable without
declaring it first. That is bad style. Use the "var" keyword to
declare and define a local variable instead (var trans = ...).
document.write("")
This statement overwrites the current document. I am astonished that
window.location.href=trans;
is ever executed. Surely it will not in all UAs. Remove it.
}
else {}
An empty "else" block is nonsense. Remove it and the "else" statement.
}


You should watch more for Pretty Printing, especially indentation.
It makes your code easier legible and thus understandable.
PointedEars
Jul 23 '05 #3
look I'don't see the answer!
My ASP code does not get executed...
the popup window works and while it works i don't give a flying f*** about
the sintax and proper coding

Can you tell me why the asp code ("request("action")) doe not get executed
unless i manually refresh the page or put a document.write("") before the
location.href

'my damn asp code
<%response.write(request("action"))%>
function confirmDelete(x){
var potvrda=confirm("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
trans="files.asp?action="+x;
document.write("")
window.location.href=trans}
else {}
}
Jul 23 '05 #4
nick schrieb:
^^^^
Who?
look I'don't see the answer!
That's your problem.
My ASP code does not get executed...
Then why you ask in a J(ava)Script/ECMAScript group?
Ask in an ASP group.
the popup window works and while it works i don't give a flying f*** about
the sintax and proper coding


You don't want to learn anything. Why should I give "a flying f***"
about you(r problems)? This is not a (paid) support forum but a
discussion group (providing free advice). Go away.
PointedEars
Jul 23 '05 #5
Lee
nick said:

look I'don't see the answer!
My ASP code does not get executed...
the popup window works and while it works i don't give a flying f*** about
the sintax and proper coding

Can you tell me why the asp code ("request("action")) doe not get executed
unless i manually refresh the page or put a document.write("") before the
location.href


It probably has to do with the way that your function is being
invoked, which you haven't shown us.

My guess is that it's in an onclick handler of a link, and the
current page is being reloaded when the link is followed.
That would be because you need to learn syntax and proper coding.

Jul 23 '05 #6
First of all I'm not a javascript programmer!
Second I repeat everything i said in my last post
Third if you don't know the solution or PLEASE do not reply to this post

This code when saved as an *.asp file should show a link which, when
pressed, shows a dialog which should redirect the page to itself including
some data in the url
the only way i got the page to reload (with the data included in the url) is
to put document.write("") (now commented) before the location.href=... (or
to manually refresh the page)
BEGIN CODE

<script language="javascript">
<!--
function confirmDelete(x)
{
if (confirm("Kliknite OK za brisanje. Cancel za povratak.")==true)
{trans="test.asp?action=delete&nID="+x;
//document.write("");
window.location.href = trans; }
}
//-->
</script>
<body>
<%
'//ASP CODE
if request("action")="delete" then response.write request("action")
%>
<a href="javascript:;" onclick="confirmDelete(15)">[obriči]</a>
</body>
END CODE

Jul 23 '05 #7

My ASP code does not get executed...
Then why you ask in a J(ava)Script/ECMAScript group?
Ask in an ASP group.


it is related more to javascript than asp
the popup window works and while it works i don't give a flying f*** about the sintax and proper coding


You don't want to learn anything. Why should I give "a flying f***"
about you(r problems)? This is not a (paid) support forum but a
discussion group (providing free advice). Go away.


I asked for some help and all I found is you writing a smart-ass post which
shows an increddible attitude.
And you did not even point me in the direction of the solution - that is not
because you don't know but because you DIDN't CARE to even try to understand
the problem.

Up yours MAN!
Jul 23 '05 #8
Kreso wrote on 16 jun 2004 in comp.lang.javascript:
First of all I'm not a javascript programmer!
Second I repeat everything i said in my last post
Third if you don't know the solution or PLEASE do not reply to this
post

This code when saved as an *.asp file should show a link which, when
pressed, shows a dialog which should redirect the page to itself
including some data in the url
the only way i got the page to reload (with the data included in the
url) is to put document.write("") (now commented) before the
location.href=... (or to manually refresh the page)
BEGIN CODE

<script language="javascript">
<!--
function confirmDelete(x)
{
if (confirm("Kliknite OK za brisanje. Cancel za povratak.")==true)
{trans="test.asp?action=delete&nID="+x;
//document.write("");
window.location.href = trans; }
}
//-->
</script>
<body>
<%
'//ASP CODE
if request("action")="delete" then response.write request("action")
%>
<a href="javascript:;" onclick="confirmDelete(15)">[obriči]</a>
</body>
END CODE

change this:
onclick="confirmDelete(15);"
to:
onclick="confirmDelete(15);return false;"

Otherwise it is all a question of timing which process fires first

================================================

Furthermore you could clean up your code:

[
1 Superfluous is the testing if a boolean is true,
the result being the same as the original boolean]
2 The href="javascript:;" will not run if javscript is not active,
and it will not run if it is
]

=================================================

<%@Language=vbscript%>

<script type="text/javascript">
function confirmDelete(x) {
if (confirm("Kliknite OK za brisanje. Cancel za povratak."))
{
window.location.href = "test.asp?action=delete&nID="+x;
}
}
</script>

<body>
Action:
<% = response.write request("action") %>
<br>
ID:
<% = response.write request("ID") %>
<br>
<a href="#"
onclick="confirmDelete(15);return false">
[obriči]</a>
</body>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #9
THANK YOU!!

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Kreso wrote on 16 jun 2004 in comp.lang.javascript:
First of all I'm not a javascript programmer!
Second I repeat everything i said in my last post
Third if you don't know the solution or PLEASE do not reply to this
post

This code when saved as an *.asp file should show a link which, when
pressed, shows a dialog which should redirect the page to itself
including some data in the url
the only way i got the page to reload (with the data included in the
url) is to put document.write("") (now commented) before the
location.href=... (or to manually refresh the page)
BEGIN CODE

<script language="javascript">
<!--
function confirmDelete(x)
{
if (confirm("Kliknite OK za brisanje. Cancel za povratak.")==true)
{trans="test.asp?action=delete&nID="+x;
//document.write("");
window.location.href = trans; }
}
//-->
</script>
<body>
<%
'//ASP CODE
if request("action")="delete" then response.write request("action")
%>
<a href="javascript:;" onclick="confirmDelete(15)">[obriči]</a>
</body>
END CODE

change this:
onclick="confirmDelete(15);"
to:
onclick="confirmDelete(15);return false;"

Otherwise it is all a question of timing which process fires first

================================================

Furthermore you could clean up your code:

[
1 Superfluous is the testing if a boolean is true,
the result being the same as the original boolean]
2 The href="javascript:;" will not run if javscript is not active,
and it will not run if it is
]

=================================================

<%@Language=vbscript%>

<script type="text/javascript">
function confirmDelete(x) {
if (confirm("Kliknite OK za brisanje. Cancel za povratak."))
{
window.location.href = "test.asp?action=delete&nID="+x;
}
}
</script>

<body>
Action:
<% = response.write request("action") %>
<br>
ID:
<% = response.write request("ID") %>
<br>
<a href="#"
onclick="confirmDelete(15);return false">
[obriči]</a>
</body>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 23 '05 #10

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

Similar topics

5
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and...
3
by: saiho.yuen | last post by:
Hi, Is anyone know what is the difference between Location.href and Window.location.href Thanks you very much:) Saiho
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
2
by: yogesh.bhardwaj | last post by:
Hello all I am trying to modify the link URL when a user clicks on the link. Following is the code: <a onClick="document.location.href=modifyURL(this.href);" href="SOME_DYNAMIC_URL"...
13
by: Jerry Manner | last post by:
Hi I have a problem using the location.href("ProductL.htm") javascript code. Using this code on my system ( W98 SE, IE 6.0) is working correctly. But if a user has W2000 IE 5.0 it doesn't work....
3
by: Christian Hubinger | last post by:
Hi! I'm working on a page that uses javascript very much. My problem is now that i cannot redirect to another page in IE with window.location =<URL>; This command gets executed (proofed with...
9
by: permanent.tourist | last post by:
I'm having a hell of a job getting this to work in Safari: the only thing I can think of is that one can't use reload() across to another frame for security reasons. Does anyone have a concrete...
11
by: whisher | last post by:
Hi. Sorry to disturb you but I can't figure out its use in this snippet (Found in many scripts about Ajax) function loadpage(page_request, containerid) { if (page_request.readyState == 4 &&...
3
by: stephen.cunliffe | last post by:
Hi all, This may sound real strange, but I'm curious what the "official" answer is. In my JS, I want to redirect/navigate to a url... In Mozilla, document.location.href = '{my_url}'; ...
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
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?
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...
0
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...
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.