473,671 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stop refresh windows?

Dear All,

I am a beginner in javascript and looking for help, I put the following
script in the original.asp:

function NewWindows()
{
window.open("ab c.asp", "new")
}

Everytime after the script is run, the original.asp will refresh itself and
the browser will go back to the top, there is something new at the tail of
url likes original.asp?x= 42&y=6, the value of x and y will be different
every refresh, is it possible to stop the refresh of orignal.asp? Thanks for
help.
Jul 20 '05 #1
6 11658
"Baffin Shea" <ba****@shea.co m> writes:
Everytime after the script is run, the original.asp will refresh itself and
the browser will go back to the top, there is something new at the tail of
url likes original.asp?x= 42&y=6, the value of x and y will be different
every refresh, is it possible to stop the refresh of orignal.asp?


It is not the function you showed us that refreshes the original.asp
page. It is most likely the method you use to call it.

My guess is that you have something like:
<input type="image" src="..." onclick="NewWin dows()">
or perhaps the call to NewWindows is inside an image map.

In any case, you should stop the click that activate NewWindows from
having its normal effect. You do that by adding a "return false"
at the end of the onclick attribute:
onclick="NewWin dows();return false;"

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
"Baffin Shea" <ba****@shea.co m> wrote in message
news:3f******** @newsgate.hknet .com...
I am a beginner in javascript and looking for help,
OK, save yourself from making the error of producing unreliable scripts
by never attempting to open a new window from a web browser. It may look
easy, you may see it consistently working in your controlled and
predictable test environment and there may even be thousands of examples
and instances of other people attempting it, but on the Internet the
outcome of that simple call to - window.open - is so unpredictable as to
make any planned design that involves the attempt impractical.
I put the following script in the original.asp:

function NewWindows()
{
window.open("ab c.asp", "new")
}

Everytime after the script is run, the original.asp will refresh
itself and the browser will go back to the top, there is something
new at the tail of url likes original.asp?x= 42&y=6, the value of x
and y will be different every refresh, is it possible to stop the
refresh of orignal.asp? Thanks for help.


There is nothing about the - window.open - function (assuming that it is
implemented on the browser and has not been replaced by a content
inserting/re-writing proxy) that would induce a re-load of the current
page. The problem is probably connected with how this function is
called. My guess (because of the query string) is that you have a
failure to cancel the default action in a form that is calling this
function in its onsubmit handler or from an event connected with one
type of submit button (be it <input type="submit">, <input type="image">
or <button>).

Without seeing how the function is called it is impossible to say.

Richard.
Jul 20 '05 #3
Dear Lasse,

Thank you for you help. However, you method will work only in the preview of
ms-frontpage, it doesn't work anymore after upload the .asp to the server
and browse it using IE, any suggestion?

Baffin
"Lasse Reichstein Nielsen" <lr*@hotpop.com >
???????:r8***** *****@hotpop.co m...
"Baffin Shea" <ba****@shea.co m> writes:
Everytime after the script is run, the original.asp will refresh itself and the browser will go back to the top, there is something new at the tail of url likes original.asp?x= 42&y=6, the value of x and y will be different
every refresh, is it possible to stop the refresh of orignal.asp?


It is not the function you showed us that refreshes the original.asp
page. It is most likely the method you use to call it.

My guess is that you have something like:
<input type="image" src="..." onclick="NewWin dows()">
or perhaps the call to NewWindows is inside an image map.

In any case, you should stop the click that activate NewWindows from
having its normal effect. You do that by adding a "return false"
at the end of the onclick attribute:
onclick="NewWin dows();return false;"

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #4
Dear Richard,

Thanks for your reply, I call the function like this:

<head>
:
:
<script language=javasc ript>
function NewWindow()
{
window.open("ab c.asp", "new")
}
:
:
</script>
</head>

<body>
:
:
<form>
<input type=image src="cde.gif" onclick="NewWin dow()">
</form>
:
:
</body>

Do you have any idea. Thank you.

Regards,
Baffin
"Richard Cornford" <Ri*****@litote s.demon.co.uk> ¼¶¼g©ó¶l¥ó·s»D
:bj************ *******@news.de mon.co.uk...
"Baffin Shea" <ba****@shea.co m> wrote in message
news:3f******** @newsgate.hknet .com...
I am a beginner in javascript and looking for help,


OK, save yourself from making the error of producing unreliable scripts
by never attempting to open a new window from a web browser. It may look
easy, you may see it consistently working in your controlled and
predictable test environment and there may even be thousands of examples
and instances of other people attempting it, but on the Internet the
outcome of that simple call to - window.open - is so unpredictable as to
make any planned design that involves the attempt impractical.
I put the following script in the original.asp:

function NewWindows()
{
window.open("ab c.asp", "new")
}

Everytime after the script is run, the original.asp will refresh
itself and the browser will go back to the top, there is something
new at the tail of url likes original.asp?x= 42&y=6, the value of x
and y will be different every refresh, is it possible to stop the
refresh of orignal.asp? Thanks for help.


There is nothing about the - window.open - function (assuming that it is
implemented on the browser and has not been replaced by a content
inserting/re-writing proxy) that would induce a re-load of the current
page. The problem is probably connected with how this function is
called. My guess (because of the query string) is that you have a
failure to cancel the default action in a form that is calling this
function in its onsubmit handler or from an event connected with one
type of submit button (be it <input type="submit">, <input type="image">
or <button>).

Without seeing how the function is called it is impossible to say.

Richard.

Jul 20 '05 #5
"Baffin Shea" <ba****@shea.co m> wrote in message
news:3f******** @newsgate.hknet .com...
<snip>
<form>
<input type=image src="cde.gif" onclick="NewWin dow()">
</form> <snip>Do you have any idea. Thank you.

<snip>

As Lasse and I suspected, the problem is the failure to cancel the
default action on he input element (which is to submit the form to the
URL specified in the (missing) action attribute of the form element).
And Lasse's suggestion of adding - return false; - to the onclick
handler will cancel that action in all of the browsers that support the
onclick event on <input type="image"> elements. Wider support can be
achieved by providing the FORM element with an onsubmit handler that
cancels the submit by returning false.

I still think it would be better to abandon the window opening idea
entirely but, given what the script does now, it is possible to achieve
exactly the same effect with pure HTML (and if something can be done
with HTML instead of JavaScript it should be done with HTML). If the
FORM element specified "abc.asp" as its ACTION attribute and had a
TARGET attribute of "_blank" you cold forget the script entirely and
achieve the same result:-
<form action="abc.asp " name="fName" target="_blank" >
<input type=image src="cde.gif" alt="???">
</form>

One of the advantages of a pure HTML approach to opening new window is
that it reduces the number of possible outcomes when the user clicks the
button down to four. And it is much easier to design a workable UI if a
user action only results in any one of four unpredictable consequences.
One would be ideal but it is still and improvement on the six or seven
possible outcomes of the JavaScript based attempt.

Richard.
Jul 20 '05 #6
Dear Richard,

In fact, I designed using html instead of javascript, it's much more easier.
But a new window will be popup everytime if the button have been clicked.
What I want to do is a new window will be popup in the first time clicking
on the button, and then the window will only be updated and refreshed when
the second time the button to be clicked.

The javascript can do the work:
window.open("ab c.asp", "new")

Can it be replaced by the html? If so, then everytime is easier.

p/s: I tried the Lasse's method, it works in Frontpage environment, but
doesn't work after uploading the file in the server.

Thank you.

Regards,
Baffin


"Richard Cornford" <Ri*****@litote s.demon.co.uk> ¼¶¼g©ó¶l¥ó·s»D
:bj************ *******@news.de mon.co.uk...
"Baffin Shea" <ba****@shea.co m> wrote in message
news:3f******** @newsgate.hknet .com...
<snip>
<form>
<input type=image src="cde.gif" onclick="NewWin dow()">
</form>

<snip>
Do you have any idea. Thank you.

<snip>

As Lasse and I suspected, the problem is the failure to cancel the
default action on he input element (which is to submit the form to the
URL specified in the (missing) action attribute of the form element).
And Lasse's suggestion of adding - return false; - to the onclick
handler will cancel that action in all of the browsers that support the
onclick event on <input type="image"> elements. Wider support can be
achieved by providing the FORM element with an onsubmit handler that
cancels the submit by returning false.

I still think it would be better to abandon the window opening idea
entirely but, given what the script does now, it is possible to achieve
exactly the same effect with pure HTML (and if something can be done
with HTML instead of JavaScript it should be done with HTML). If the
FORM element specified "abc.asp" as its ACTION attribute and had a
TARGET attribute of "_blank" you cold forget the script entirely and
achieve the same result:-
<form action="abc.asp " name="fName" target="_blank" >
<input type=image src="cde.gif" alt="???">
</form>

One of the advantages of a pure HTML approach to opening new window is
that it reduces the number of possible outcomes when the user clicks the
button down to four. And it is much easier to design a workable UI if a
user action only results in any one of four unpredictable consequences.
One would be ideal but it is still and improvement on the six or seven
possible outcomes of the JavaScript based attempt.

Richard.

Jul 20 '05 #7

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

Similar topics

11
2707
by: brendan | last post by:
Sorry this isnt a cross post .. i just didnt get any help from alt.php. I have a website which utilises post forms for navigation in some areas. Problem is, when *some* users hit the BACK button the POSTDATA content has expired and they need to refresh the page then they get a alert about refreshing expired data. I am getting complaints that this is too annoying and limits the sites useability.
13
3794
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a counter functionality and read/insert some data in a MS Access database on that Windows 2003 server. The weird part is, as long as the web page is very short in size, I can hit the refresh button and Internet Explorer will reload the page and display...
11
3751
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
8
3514
by: Matt Theule | last post by:
While stepping through an ASP.NET project, I found that data was being inserted into my database even though I was not stepping through the code that inserted the data. I have a single page with inline code. The page has a Datagrid, a textbox and a button. When the button is clicked, the value of the textbox is inserted into the table whose contents are displayed on the page. The problem occurs when I set a breakpoint on a line *IN*...
7
15438
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
3
1782
by: Ben | last post by:
Hi We have a windows form that takes a while to run a routine. During this we have created a information label, updating the user on the progress but: a) The changes on the label are not visible until the routine has finished b) If the form looses focus it appears to the user that it has crashed
4
2507
by: ravindarjobs | last post by:
hi...... i am using ms access 2003,vb6 i have a form. in that i have 2 buttons 1. start search 2 stop search when i click the "start search" button the fucntion SearchSystem() is called, it will search for a particular file in the computer(searches entire drives).
0
2188
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never start or stop main service manually, only updater). On most computers it works great, the updater's onStop() can start and stop the main service perfectly. On some computers, though, the updater hangs when it tries to stop the main service. It...
1
3468
by: Matthew Wells | last post by:
Hello. I'm trying to use an asp - not html - button without having a postback or a screen refresh. I've tried turning off "CausesValidation" and "UseSubmitBehavior" and I still get a screen refresh - which makes me think I'm doing a postback. I've also tried "return false" in both the onclick and OnClientClick events. No Luch. Can I use the onclick or OnClientClick (or something else) to fire a javascritpt function and then stop? ...
0
8476
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
8393
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
8917
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
8670
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
7437
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...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.