Hi All
I'm using the same style of form on a number of pages, but for some reason
the exact same one liner on one my pages doesn't do anything. The one liner
is:
<INPUT TYPE="BUTTON" onClick="location.href='admin.asp?sec=4&folder=32' "
CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
Basically the user clicks this button and it takes the back to the main
page, which is actually the same page, but the 'sec' determines what routine
the page is going to run and display.
The above works fine on my other pages, but not on one particular page so I
must have something in this page that is stopping it from working, but I
can't see what.
If I put an alert before the location.href bit, eg
onClick="alert('hello');location.href='admin.asp.. ., then the alert does
appear when I click the button, which means it's my location ref that is
fouling up.
What is even weirder is that if I stick window. in front of the
location.href command then it works, eg:
<INPUT TYPE="BUTTON"
onClick="window.location.href='admin.asp?sec=4&fol der=32'"
CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
I know this solves my problem, but I'd like to know why this is the case.
Any help you can give would be appreciated.
Rgds Laphan 8 2695
Laphan wrote: What is even weirder is that if I stick window. in front of the location.href command then it works, eg:
<INPUT TYPE="BUTTON" onClick="window.location.href='admin.asp?sec=4&fol der=32'" CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
I know this solves my problem, but I'd like to know why this is the case.
Impossible to say w/o seeing the page itself. But the situation:
windows.location works - location doesn't gives a strong hint that on
this page you have:
a custom JavaScript object named "location"
or
an HTML element having id "location"
Also is it a single page or a frameset?
Did you also try:
onClick="window.location.href='admin.asp?sec=4&fol der=32'+(new
Date).getTime();"
Laphan wrote on 04 dec 2005 in comp.lang.javascript : <INPUT TYPE="BUTTON" onClick="window.location.href='admin.asp?sec=4&fol der=32'" CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
I know this solves my problem, but I'd like to know why this is the case.
It probably is a matter of timing,
while the form-submit also executes.
Try:
<INPUT TYPE="BUTTON"
onClick="location.href='admin.asp?sec=4&folder=32' ;return false;"
CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
or:
<BUTTON
onClick="location.href='admin.asp?sec=4&folder=32' ;"
CLASS="FormButton">Go back to list</BUTTON>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Laphan wrote: Hi All
I'm using the same style of form on a number of pages, but for some reason the exact same one liner on one my pages doesn't do anything. The one liner is:
<INPUT TYPE="BUTTON" onClick="location.href='admin.asp?sec=4&folder=32' " CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
Basically the user clicks this button and it takes the back to the main page, which is actually the same page, but the 'sec' determines what routine the page is going to run and display.
The above works fine on my other pages, but not on one particular page so I must have something in this page that is stopping it from working, but I can't see what.
If I put an alert before the location.href bit, eg onClick="alert('hello');location.href='admin.asp.. ., then the alert does appear when I click the button, which means it's my location ref that is fouling up.
What is even weirder is that if I stick window. in front of the location.href command then it works, eg:
<INPUT TYPE="BUTTON" onClick="window.location.href='admin.asp?sec=4&fol der=32'" CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
I know this solves my problem, but I'd like to know why this is the case.
Any help you can give would be appreciated.
You may have a global variable named 'location', or you may have used
it for the name or id of an element somewhere. Try replacing the
onclick value with 'alert(location)' and see what happens, or search
for the string 'location' in the code.
--
Rob
Laphan wrote: I'm using the same style of form on a number of pages, but for some reason the exact same one liner on one my pages doesn't do anything. The one liner is:
<INPUT TYPE="BUTTON" onClick="location.href='admin.asp?sec=4&folder=32' " CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
<snip> What is even weirder is that if I stick window. in front of the location.href command then it works, eg:
<snip> I know this solves my problem, but I'd like to know why this is the case.
It is going to be scope chain thing. There is something on the scope
chain of the event handler in that one page that is not present on the
other. Pure guess-work would suggest a form control with the name
'location'(so with the FORM element on the scope chain the Identifier
'location' refers to a named property of that FORM element, a reference
to the form control), but without being able to see the HTML it is not
possible to say for sure.
Richard.
On 2005-12-04, Laphan <in**@SpamMeNot.co.uk> wrote:
[not working] <INPUT TYPE="BUTTON" onClick="location.href='admin.asp?sec=4&folder=32' " CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
What is even weirder is that if I stick window. in front of the location.href command then it works, eg:
possibly you have a field on that page called "location" ?
Bye.
Jasen
VK wrote: Did you also try: onClick="window.location.href='admin.asp?sec=4&fol der=32'+(new Date).getTime();"
Wow. Possibly the worst advice I've yet seen. Not only is this clearly
not a caching issue, but your date string is concatenated to the
"folder" value.
Thank you for pointing to my typo. Sh** happens :-)
onClick="window.location.href='admin.asp?sec=4&fol der=32&rnd='+(new
Date()).getTime();"
Unlikely but it may be a caching issue if URL
'admin.asp?sec=4&folder=32' has been already called during the session.
If it is not an issue yet then it eventually will be somewhere
sometimes if one uses GET method: it is enough to request the same asp
page more than once. So unrelated to the current problem link
randomization would be a good idea.
I would still bet on my first idea (global [location] var or object
interfering with window.location
And the prize goes to Master Betts!!!
Thanks Jason (and everybody else for their help). I've just noticed that
I've named one of my fields as location when I want to name it as loc.
Doh!!! Doh !! Doh!!
Rgds
"Jasen Betts" <ja***@free.net.nospam.nz> wrote in message
news:39*****************@clunker.homenet...
On 2005-12-04, Laphan <in**@SpamMeNot.co.uk> wrote:
[not working] <INPUT TYPE="BUTTON" onClick="location.href='admin.asp?sec=4&folder=32' " CLASS="FormButton" TABINDEX=41 VALUE='Go back to list'>
What is even weirder is that if I stick window. in front of the location.href command then it works, eg:
possibly you have a field on that page called "location" ?
Bye.
Jasen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike Gratee |
last post by:
Is it possible to use JavaScript to cause the browser to click a link on a
page and have the browser act exactly like the user had clicked on the link
directly?
In other words, I need to...
|
by: RobG |
last post by:
I am trying to dynamically add an onclick to an element,
however I just can't get the syntax right. consider the
following function:
function doClick (evt,x) {
// do things with evt and x
}
...
|
by: Donius |
last post by:
Hey everyone, i am doing some stuff where i'd like to pop up a little
confirmation before a user clicks on a 'delete' link. Just trying to
keep the markup clean, i added an attribute ...
|
by: phish.guy |
last post by:
How do I call another event's onclick function from a button press? I
have stored information dynamically created in a div onclick function
that is not accessible directly by the button, but i...
|
by: Todd |
last post by:
Hello
We have a page that loads a long list of things. Each row has an onclick
where you can open a window for more information. When you do that the parent
page refreshes to the top of the...
|
by: alvin.yk |
last post by:
Hi,
Normally, a piece of code such as
<a href="http://www.yahoo.com" onclick="alert('hello');return
false;">link</a>
will stop the browser from actually going to href's destination....
|
by: SM |
last post by:
Hello,
I have an <ul>, and when i click on a item i want to add a class to
that item. The class itself will change some display properties, using
CSS. See code below.
But, whenever i click on a...
|
by: DavidGeorge |
last post by:
In an earlier thread I recounted a problem I was having, but it took a
while to reduce the problem to it's basic components and the issue
became somewhat confused in reaching that point. I hope you...
|
by: cprice |
last post by:
Hello.
Issue:
When the page loads, we are dynamically adding an OnClick event to each link.
The onClick event calls a webservice.
Once the target of the link loads, the HTTP_REFERER...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |