473,785 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=deletef ile 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.as p?action="+x;
document.write( "")
window.location .href=trans;
}
else {}
}
Jul 23 '05 #1
9 2363
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.as p?action="+x;
You should use the escape() or encodeURICompon ent() 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.as p?action="+x;
You should use the escape() or encodeURICompon ent() 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("acti on")) doe not get executed
unless i manually refresh the page or put a document.write( "") before the
location.href

'my damn asp code
<%response.writ e(request("acti on"))%>
function confirmDelete(x ){
var potvrda=confirm ("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
trans="files.as p?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("acti on")) doe not get executed
unless i manually refresh the page or put a document.write( "") before the
location.hre f


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="javas cript">
<!--
function confirmDelete(x )
{
if (confirm("Klikn ite OK za brisanje. Cancel za povratak.")==tr ue)
{trans="test.as p?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="javascrip t:;" onclick="confir mDelete(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.javas cript:
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="javas cript">
<!--
function confirmDelete(x )
{
if (confirm("Klikn ite OK za brisanje. Cancel za povratak.")==tr ue)
{trans="test.as p?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="javascrip t:;" onclick="confir mDelete(15)">[obri¹i]</a>
</body>
END CODE

change this:
onclick="confir mDelete(15);"
to:
onclick="confir mDelete(15);ret urn 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="javascrip t:;" will not run if javscript is not active,
and it will not run if it is
]

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

<%@Language=vbs cript%>

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

<body>
Action:
<% = response.write request("action ") %>
<br>
ID:
<% = response.write request("ID") %>
<br>
<a href="#"
onclick="confir mDelete(15);ret urn 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******** ************@19 4.109.133.29...
Kreso wrote on 16 jun 2004 in comp.lang.javas cript:
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="javas cript">
<!--
function confirmDelete(x )
{
if (confirm("Klikn ite OK za brisanje. Cancel za povratak.")==tr ue)
{trans="test.as p?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="javascrip t:;" onclick="confir mDelete(15)">[obri¹i]</a>
</body>
END CODE

change this:
onclick="confir mDelete(15);"
to:
onclick="confir mDelete(15);ret urn 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="javascrip t:;" will not run if javscript is not active,
and it will not run if it is
]

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

<%@Language=vbs cript%>

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

<body>
Action:
<% = response.write request("action ") %>
<br>
ID:
<% = response.write request("ID") %>
<br>
<a href="#"
onclick="confir mDelete(15);ret urn 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
7545
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 IE. I link within a page and display individual divisions of that page, manipulating their visibility and display styles with an onClick function. As long as I explicitly click a link to progress, it works with browsers I've tried.
3
50430
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
8245
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) { document.location.href = document.location.href.substring(0, document.location.href.indexOf('#')) + '?' + newUrl; } else { document.location.href = document.location.href + '?' + newUrl; }
2
41508
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" %>Link</a> The javascript function, modifyURL(href), works fine and returns the desired URL, but for some reason, the value of 'href' is not getting
13
2194
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. When using this code the browser shows an error on page in the statusbar. If I click on the statusbar to find out what is causing the error I see this description 'The property of this method is not supported by this object' ( I have translated...
3
23009
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 alert messages) but nothing happens. FF acts like expected but i cant get it work in IE. What can be the problem here? here the code i use:
9
5444
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 answer or solution for this? I'm trying to do this: top.frames.location.reload(); Thanks Mark Howells www.permanenttourist.ch
11
14657
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 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) { document.getElementById(containerid).innerHTML=page_request.responseText;
3
8798
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}'; //works in Moz, IE6, IE7, Opera,
0
9645
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
9480
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
10325
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...
0
10148
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
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...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
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();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.